|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-02-25 18:10 UTC] stephin at stephin dot in
Description:
------------
php -r "echo intval('1e10');"
expected output: 1
actual output: 10000000000
i have tested this in some of other previous version series and found only php 7.1.x have this bug.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
this is for most cases a bugfix where before PHP7.1 when something returned scientific notation because of 0.0000000000001 you got weird results and lost data i have some workarounds in several scripts to prevent that which are ugly if(strpos($out, 'E') || strpos($out, 'e')) { $out = rtrim(number_format((float)$out, 20), '0'); } http://php.net/manual/de/migration71.incompatible.php Numerical string conversions now respect scientific notation Integer operations and conversions on numerical strings now respect scientific notation. This also includes the (int) cast operation, and the following functions: intval() (where the base is 10), settype(), decbin(), decoct(), and dechex()php 7.1.2 php -r "echo intval('354e3318D2174C4196I7371p2214T3183F6594X2108');" output: 0 why should it be 0? other previous version series php -r "echo intval('354e3318D2174C4196I7371p2214T3183F6594X2108');" output: 354