Comment 3 for bug 184747

Revision history for this message
Russell Smith (mr-russ) wrote :

My understanding is 64bit machines use 64bit integers, so 1 <<31 doesn't overflow on 64bit. However on 32bit is does overflow. Even though an unsigned integer is being printed, a signed integer is being calculated as shown below;

printf("%s\n", (1 << 31)); returns -2147483648

This suggests it's wrapped back to the other end of the signed loop.

I believe the issue is that you wrap a signed integer on 32bit, and then php doesn't get you back from the edge to give meaningful values. I don't have the php debugging skills to nail down the specific issue with integer wraparound. But that is certainly what's being experienced.

PHP Version
--
PHP 5.2.4-2ubuntu5 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb 27 2008 20:43:54)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies