#50080 [Opn->Bgs]: 1 bit short of an 8 byte integer
by jani other posts by this author
Nov 4 2009 2:52PM messages near this date
#50080 [Bgs]: 1 bit short of an 8 byte integer
|
#50080 [Com]: 1 bit short of an 8 byte integer
ID: 50080
Updated by: jani@[...].net
Reported By: aidevelopment at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: Linux 2.6.15-26-server
PHP Version: 5.2.11
New Comment:
No.
Previous Comments:
------------------------------------------------------------------------
[2009-11-04 17:59:05] aidevelopment at gmail dot com
I understand what you are saying. However, the handling is very
difficult to understand. As you can see, adding 1 simply has no effect
past positive 0
(1000000000000000000000000000000000000000000000000000000000000000). I
have not been able to determine yet exactly what happens when you
explicitly assign a variable to a value "too large".
Is there no way to have PHP utilize 64 bit values (uint64)?
------------------------------------------------------------------------
[2009-11-04 17:17:58] sjoerd@[...].net
In a 64 bit integer, 1 bit indicates the sign and 63 bits are left for
the number. Thus the range is from -2^63 to 2^63, giving 2^64 numbers.
------------------------------------------------------------------------
[2009-11-04 16:14:21] aidevelopment at gmail dot com
Description:
------------
Despite having PHP_INT_MAX set to 8 bytes, It is impossible to have an
int greater than
1000000000000000000000000000000000000000000000000000000000000000.
8 Byte, or 64 bit maximum should be
1111111111111111111111111111111111111111111111111111111111111111.
In my included example, it is clear that when attempting to increase
the value above(by adding 1), simply nothing happens.
Attempting to assign a variable to a number greater than the above
number produces unpredictable results.
Reproduce code:
---------------
<?php
echo "Int Size = ".PHP_INT_SIZE." bytes.<br> ";
$status = 0x7FFFFFFFFFFFFFFF;
for($i=0;$i<=4;$i++)
{
printf ("status = '%b'<br> ", $status);
$status++;
}
?>
Expected result:
----------------
Int Size = 8 bytes.
status =
'111111111111111111111111111111111111111111111111111111111111111'
status =
'1000000000000000000000000000000000000000000000000000000000000000'
status =
'1000000000000000000000000000000000000000000000000000000000000001'
status =
'1000000000000000000000000000000000000000000000000000000000000010'
status =
'1000000000000000000000000000000000000000000000000000000000000011'
Actual result:
--------------
Int Size = 8 bytes.
status =
'111111111111111111111111111111111111111111111111111111111111111'
status =
'1000000000000000000000000000000000000000000000000000000000000000'
status =
'1000000000000000000000000000000000000000000000000000000000000000'
status =
'1000000000000000000000000000000000000000000000000000000000000000'
status =
'1000000000000000000000000000000000000000000000000000000000000000'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50080&edit=1
Thread:
Aidevelopment At Gmail Dot Com
Aidevelopment At Gmail Dot Com
jani
Aidevelopment At Gmail Dot Com
sjoerd
|