davlee Posted July 11, 2014 Share Posted July 11, 2014 I'm having problems running a php program on my Linux box which runs fine on my Windows box. I traced the problem down to a line of code: $higherValue = 0xFFFFFFFF; This should be an maximum unsigned int value of 4294967295, but PHP doesn't handle unsigned int so it should convert it to a float. This is not happening on my system. Instead it is just converting it to a max int value of 2147483647. I wrote a small php test script: var_dump(0x00000000); var_dump(0xFFFFFFFF); var_dump(0xFFFFFFFE); On Windows: int(0) float(4294967295) float(4294967294) On Linux: int(0) int(2147483647) int(2147483647) Versions: Windows: >.\win32\php -c php-win.ini -v PHP 5.3.15 (cli) (built: Jul 20 2012 00:20:38) Copyright © 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright © 1998-2012 Zend Technologies Linux: > php -v PHP 5.3.27 (cli) (built: Jun 24 2014 01:48:44) Copyright © 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright © 1998-2013 Zend Technologies How do I get integer overflow working? Do I have a bad build of PHP? Link to comment https://forums.phpfreaks.com/topic/289747-php-interger-overflow-handling-help/ Share on other sites More sharing options...
mikosiko Posted July 11, 2014 Share Posted July 11, 2014 In your Linux Box what echo PHP_INT_MAX produce? from the manual The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except for Windows, which is always 32 bit. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5. Link to comment https://forums.phpfreaks.com/topic/289747-php-interger-overflow-handling-help/#findComment-1484702 Share on other sites More sharing options...
davlee Posted July 11, 2014 Author Share Posted July 11, 2014 Size = 4, Max = 2147483647 Link to comment https://forums.phpfreaks.com/topic/289747-php-interger-overflow-handling-help/#findComment-1484718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.