Req #45688 [Opn]: 64bit unsigned integers, or provide a workaround.

From: Date: Fri, 09 Jan 2015 03:01:15 +0000
Subject: Req #45688 [Opn]: 64bit unsigned integers, or provide a workaround.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189819@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=45688&edit=1 ID: 45688 User updated by: andy at haveland dot com Reported by: andy at haveland dot com Summary: 64bit unsigned integers, or provide a workaround. Status: Open Type: Feature/Change Request Package: *Programming Data Structures Operating System: * PHP Version: * Block user comment: N Private report: N New Comment: Wow, 6.4 years elapsed! Thanks for the interesting link, it would be good to see it integrated into php. I think I ended up using perl to restructure the directory tree from /xxx/xxx/xxx/xxxxxxxxxxx.jpg to /xxx/xxx/xxxxxxxxxxxxxx.jpg Three levels was way overkill for just half a million images. Previous Comments: ------------------------------------------------------------------------ [2015-01-09 01:23:17] ajf@php.net This RFC would deal with this, indirectly: http://wiki.php.net/rfc/bigint ------------------------------------------------------------------------ [2008-08-02 14:14:23] andy at haveland dot com 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 this bug report at https://bugs.php.net/bug.php?id=45688&edit=1

« previous php.bugs (#189819) next »