views:

24

answers:

0

Can anyone tell me why I get the following output on x64 architecture:

$ php -r 'echo pow(2, 33) . "\n";print_r(unpack("Ivalue", pack("I", pow(2, 33))));'
8589934592
Array
(
    [value] => 0
)

It seems as though it can handle signed 64bit ints, but can't pack / unpack them. According to the docs: http://us3.php.net/pack, the size of I should be machine dependent, which in this case is 64bit.

Thanks.

EDIT
Should have mentioned this in the original post:

$ php -r 'echo PHP_INT_MAX;'
9223372036854775807

EDIT 2

$ php -v
PHP 5.2.9 (cli) (built: Apr 17 2009 03:29:14)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies