It all depends I think on the system you are using. On a Win32 system the size of an integer is 4 bytes (32 bits - hence the Win32). Which allows a signed integer in the range of:
-2147483648 to 2147483647
or
-(231) to (231) - 1
When converted to binary form using the printf(0 function the number given is most probably truncated to a 4 byte integer. The above value of (231) - 1 will give us the binary value of:
01111111111111111111111111111111
Which is 32 bits/(characters) in length and your maximum possible binary value for a 4 byte integer. This is the manner in which the computer stores the interger value. With every 8'th bit counting as one byte:
| byte 1 | byte 2 | byte 3 | byte 4 |
01111111 11111111 11111111 11111111
When the number is displayed however, just as with decimal numbers, the preceeding 0's are dropped. Therefore if the first two bits are 0 then only the remain 30 will be printed.
Try plugging the number 2147483647 into your program and see if you get the result above. Then try the number 2147483648.
10000000000000000000000000000000
If you see the above this is the binary reprsentation of the decimal integer -1. The first bit which which is always 0 in a positive integer is now set to 1 to indicate the the value is negative.
If you get a number different from the one above it means the number was so large that it was converted to an 8 byte floating point number and only the first 4 bytes of it used in the function.
If you are working on a 16bit system then your integers will most probably be two bytes in size and on these new 64bit systems 8 byte integers. This does not present a major problem as you can split numbers larger than the size of an integer on the system. Converting them individually and sticking the binary results back together.
The following script converts an integer larger than the maximum into 32 bit chunks and places them in an array. Its worth remembering though that with large values there will be a loss of accuracy when PHP converts them from floats to intergers:
<?php
define ('MAX_SIZE_INT', pow(2, 31) - 1);
$bigint = 10148252870;
while ($bigint > MAX_SIZE_INT)
{
$arrInts[] = $bigint % MAX_SIZE_INT;
// conversion may affect accuracy of number
$bigint = (int) ($bigint / MAX_SIZE_INT);
}
$arrInts[] = $bigint;
var_dump($arrInts);
?>