ID:               28691
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dneilsen at davislangdon dot com dot au
 Status:           Bogus
 Bug Type:         Math related
 Operating System: RedHat Linux 8 & 9
 PHP Version:      4.3.7
 New Comment:

Because it doesn't make much sense, as they are encoded in way that
bitwise ops don't really work. (But that discussion doesn't belong in
this bugsystem).


Previous Comments:
------------------------------------------------------------------------

[2004-06-09 00:07:16] dneilsen at davislangdon dot com dot au

Thanks for the comment Derick, but why wouldnt bitwise operators work
on float numbers?

------------------------------------------------------------------------

[2004-06-08 10:02:14] [EMAIL PROTECTED]

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).

------------------------------------------------------------------------

[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

Reply via email to