From: andy at haveland dot com Operating system: Linux 2.6.25.11-97.fc9.x86_64 PHP version: 5.2.6 PHP Bug Type: Feature/Change Request Bug description: 64bit unsigned integers, or provide a workaround.
Description: ------------ I've had a look at some bogus bug reports on unsigned integers and rounding precision, and understand the issues and reasons but want to add my voice to request better integer support. bcmaths is overkill for simple bit operations. I'm trying to use php to process thousands of random 64-bit ids supplied in decimal and half have the high bit set. As they are keys in a database mapped to hierarchical directories, accuracy, speed and repeatability is a big issue. Renaming to 63 bit ids is not an option! You may consider this as a bogus request, but I think lack of unsigned support is a serious issue. Any bit operations that touch the high bit turn to mush if set, and limits php to 31 or 63 bit program! If perl can deal correctly with this, then shouldn't php be able to as well? Andy. Reproduce code: --------------- $id = 11791849344837931437; print "\$id = $id\n"; printf("\$id = 0x%x (%20u)\n", $id, $id); f($id); f(($id & 0xf000000000000000) >> 60); $idhi= $id >> 32; $idlo= $id & 0xffffffff; f2($idhi, $idlo); function f($id) { printf ("f(\$id) = 0x%x (%20u)\n", $id, $id); } function f2($idhi, $idlo) { printf ("\$idhi = 0x%x (%20u)\n", $idhi, $idhi); printf ("\$idlo = 0x%x (%20u)\n", $idlo, $idlo); } (Perl code is practically identical, apart from s/function/sub/ and param passing) Expected result: ---------------- # perl showbug.pl $id = 11791849344837931437 $id = 0xa3a51080d3fcd1ad (11791849344837931437) f($id) = 0xa3a51080d3fcd1ad (11791849344837931437) f($id) = 0xa ( 10) $idhi = 0xa3a51080 ( 2745503872) $idlo = 0xd3fcd1ad ( 3556561325) Actual result: -------------- # php showbug.php $id = 1.1791849344838E+19 $id = 0xa3a51080d3fcd000 (11791849344837931008) f($id) = 0xa3a51080d3fcd000 (11791849344837931008) f($id) = 0xfffffffffffffffa (18446744073709551610) $idhi = 0xffffffffa3a51080 (18446744072160088192) $idlo = 0xd3fcd000 ( 3556560896) -- Edit bug report at http://bugs.php.net/?id=45688&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45688&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45688&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45688&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45688&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45688&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45688&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45688&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45688&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45688&r=support Expected behavior: http://bugs.php.net/fix.php?id=45688&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45688&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45688&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45688&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45688&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45688&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45688&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45688&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45688&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45688&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45688&r=mysqlcfg