#30271 [Com]: Bitwise operator returns unwanted values
ID: 30271
Comment by: one_half at seznam dot cz
Reported By: mccohy at kyberdigi dot cz
Status: Wont fix
Bug Type: Math related
Operating System: Linux
PHP Version: 5.0.2
New Comment:
And what about to retype it to 64-bit integer ? :)) Or is that
difficult ?? :))
Previous Comments:
------------------------------------------------------------------------
[2004-10-23 20:51:23] hholzgra@php.net
-2147483649 is to big for a PHP int so it is actually treated as a
float,
and the behavior of & on floats is undefined
------------------------------------------------------------------------
[2004-10-18 00:18:37] almekind at xs4all dot nl
In php 5.0.1 it was still OK. Came with 5.0.2
------------------------------------------------------------------------
[2004-09-29 10:17:53] mccohy at kyberdigi dot cz
Description:
------------
The bitwise operator "and" returns an unwanted value. Here is a simple
example:
Let's store value 924303769 in variable $a and value -2147483649 in
variable $ax. Now, let's count the 'bitwise and' of these two variables
($a & $ax).
PHP 5.0.2 returns zero. PHP 4.3.9 returns 924303769. I am not sure what
happens in 5.0.0 or 5.0.1, sorry.
Reproduce code:
---------------
$a=924303769;
$ax=-2147483649;
echo ($a & $ax)."\n";
Expected result:
----------------
924303769
Actual result:
--------------
0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30271&edit=1
Thread (5 messages)