bindec/decbin
| From: | Cornelia Boenigk | Date: | Thu, 26 Feb 2004 14:59:01 +0000 |
| Subject: | bindec/decbin | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969359247@lists.php.net to get a copy of this message | ||
Hi
The next ;-)
Manual for bindec()
*bindec() converts a binary number to an integer. The largest number
that can be converted is 31 bits of 1's or 2147483647 in decimal.*
bindec() can handle much bigger values, see the example below.
Manual for decbin():
*Returns a string containing a binary representation of the given
number argument. The largest number that can be converted is
4294967295 in decimal resulting to a string of 32 1's.*
decbin doesn't issue an error when called with bigger values. The
function converts but truncates every bigger value to 32 digits where
the MSB are truncated.
Example:
<?php
echo bindec('11111111111111111111111111111111');
echo '<br>';
echo decbin(4294967295);
echo '<br>';
echo bindec('111111111111111111111111111111110');
echo '<br>';
echo decbin(8589934590);
echo '<br>';
echo bindec('1111111111111111111111111111111100');
echo '<br>';
echo decbin(17179869180);
echo '<br>';
echo
bindec('11111111111111111111111111111111111111111111111111111111111111
11');
?>
Result:
4294967295
11111111111111111111111111111111
8589934590
11111111111111111111111111111110
17179869180
11111111111111111111111111111100
1.844674407371E+019
Regards
Conni