|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-01-09 00:28 UTC] ajf@php.net
-Status: Open
+Status: Wont fix
-Package: Feature/Change Request
+Package: *General Issues
[2015-01-09 00:28 UTC] ajf@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
Description: ------------ When an integer operand value exceeds 2^32 the php runtime automatically converts it into float. This is completely transparent to the applications dealing with integer arithmetic. It allows PHP applications to handle integers upto 2^53. (Larger values don't work correctly due to precision limits of 64 bit floating point format). However things are not so clear when numeric values are initially expressed as strings (e.g. read from a file or network). e.g. consider following code - <?php $i1 = 4294967296; $i2 = 2147483647 * 2 + 2; $i3 = (integer) 4294967296; $i4 = (integer) "4294967296"; echo $i1 . "\n"; // prints 4294967296 echo $i2 . "\n"; // prints 4294967296 echo $i3 . "\n"; // prints 0! echo $i4 . "\n"; // prints 2147483647!! ?> Proposed fix: The "automatic conversion to float" rule should be uniformly applied in all these cases even if the program wants to explicitly cast to integer.