ID: 28691
Updated by: [EMAIL PROTECTED]
Reported By: dneilsen at davislangdon dot com dot au
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: RedHat Linux 8 & 9
PHP Version: 4.3.7
New Comment:
Not a bug, PHP doesn't support integers > 2^31 - 1 (we have a 32 bit
signed integer only, larger numbers get converted to a float).
Previous Comments:
------------------------------------------------------------------------
[2004-06-08 07:02:50] dneilsen at davislangdon dot com dot au
Description:
------------
I have tested this on two separate systems running Redhat 8 and redhat
9 respectively. The Redhat 9 system is running php version 4.3.4 and
the redhat 8 is running 4.3.7.
php.ini has not been altered and, in the case of the redhat 8 box (php
4.3.7), it was compiled with the following:
./configure --with-mysql --with-apxs=/www/bin/apxs
It seems that the bitwise AND operator will not work for values over
pow(2,30). In the case of power 31 it returns a negative value and in
the case of power 32 and above it returns 0.
Thank you for your time :)
Regards
Daniel Neilsen
Reproduce code:
---------------
<?
for($i=28; $i<34; $i++)
{
$vala = pow(2,$i);
$valb = pow(2,$i);
$result = $vala & $valb;
echo "$i - $vala & $valb = $result<br>";
}
Expected result:
----------------
28 - 268435456 & 268435456 = 268435456
29 - 536870912 & 536870912 = 536870912
30 - 1073741824 & 1073741824 = 1073741824
31 - 2147483648 & 2147483648 = 2147483648
32 - 4294967296 & 4294967296 = 4294967296
33 - 8589934592 & 8589934592 = 8589934592
Actual result:
--------------
28 - 268435456 & 268435456 = 268435456
29 - 536870912 & 536870912 = 536870912
30 - 1073741824 & 1073741824 = 1073741824
31 - 2147483648 & 2147483648 = -2147483648
32 - 4294967296 & 4294967296 = 0
33 - 8589934592 & 8589934592 = 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28691&edit=1