@NogDogAug 13.2007 — #You've probably exceeded the max integer size for your platform. To check: [code=php] echo PHP_INT_MAX; // I get 2147483647 on my PC [/code]
@bokehauthorAug 13.2007 — #Hi all, thanks for your answers. MrCoder it's not a problem I was just trying to get to the bottom of the conversion.You've probably exceeded the max integer size for your platform. To check: [code=php] echo PHP_INT_MAX; // I get 2147483647 on my PC [/code][/QUOTE]Hi Nogdog, your result is not down to the platform although it would be if the platform didn't support 32 bit integers. The result you have is the biggest signed integer it is possible to hold in a 32 bit word (PHP or C integer). Here's how it is formed:[code=php]2^32 = 4294967296
// divide by 2 to allow for positive and negative values 4294967296/2 = 2147483648
// less one slot to allow for 0 2147483648 - 1 = 2147483647[/code] Which is your result.
What I don't understand though is how the conversion is done.
Also can everyone run the example I posted above to see if they return the same result.
@NogDogAug 13.2007 — #It's just a case of the left-most 7 bits being dropped to get it down to 31 bits (32 minus the plus/minus bit): [code=php] <?php header('Content-Type: text/plain'); // Binary value of 143133271933: echo "10000101010011011010000110011101111101n"; // See what PHP does with it: echo ' ' . decbin((int)143133271933); [/code] Output: <i> </i>10000101010011011010000110011101111101 1010011011010000110011101111101