Re: Different binary results with different PHP versions



Skeleton wrote:
Yes, I have read the manual and notes below the manual. But actually, I
don't need exactly the decbin function. I have used that just to show
something going wrong. My point is the ^ operator. For ex, look at the
following code and its outputs:

echo (1 ^ -5817441119);
// Prints -1522473824 which is true result, at PHP 5.1.2 + Windows
// Prints -2147483647 which is false result, at PHP 4.4.2 + Linux

I also thought that the reason is that the number is too small, but why
PHP 5 calculates correctly? Is there a big difference in number types
between PHP 4 and PHP 5? I don't know if it helps but when I checked
PHP_INT_MAX, it is 2147483647 for both.

Be careful of your base assumptions. php 5.1.2 on Linux produces -2147483647 as well.

-david-

.



Relevant Pages