Re: base_convert bug?

From: Date: Mon, 28 Jul 2014 17:26:17 +0000
Subject: Re: base_convert bug?
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-323680@lists.php.net to get a copy of this message
On 28 July 2014 16:01:54 BST, Robert Cummings <robert@interjinn.com> wrote: >On 14-07-28 09:21 AM, Ashley Sheridan wrote: >> >> On 28 July 2014 13:59:25 BST, "Radek Krejča" ><radek.krejca@starnet.cz> wrote: >>> >>> Leading zeros are not important in a binary number. Any system can >>> detect that 00010000 == 10000. The leading zeros do not make a >>> difference when it comes to calculating the values. >>> >>> [Radek Krejca] >>> Thank you. So I have to fill missing zeros by myself. >>> >>> Radek >> >> Yes, you can use printf or sprintf to do this. The manual lists ways >of adding leading characters to a string (as this is what it >essentially needs to be to preserve the leading zeros) > >Might I suggest the str_pad() function whose entire purpose is to pad >:) > >Cheers, >Rob. Good call, sprintf is probably akin to taking a mallet (not a full sledgehammer, that's more like preg_replace() ) to a walnut! Thanks, Ash

« previous php.general (#323680) next »