Re: base_convert bug?
| From: | Aziz Saleh | Date: | Mon, 28 Jul 2014 11:56:37 +0000 |
| Subject: | Re: base_convert bug? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323673@lists.php.net to get a copy of this message | ||
On Mon, Jul 28, 2014 at 7:51 AM, Radek Krejča <radek.krejca@starnet.cz>
wrote:
> > That's not a bug, they're both the same number. Leading zeros are
> > always ignored in number systems, and PHP doesn't attempt to format it
> > assuming and specific word size. Try the same conversion in your
> > computers calculator.
> >
> > To format the number as you wish for output, use printf or sprintf to
> > pad with leading zeros.
>
> [Radek Krejca]
> Thank you for response, but maybe it is not important when we talk about
> Decimal numbers , but with binary i think it is important to keep zeros
> ,because the position of bit in the string is very
> important , to construct its value , or in Decoding ,Encoding process , it
> will be also very important .
>
> Thank you
> Radek
>
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.