|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-09-15 19:58 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2013-09-15 19:58 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 05:00:01 2025 UTC |
Description: ------------ position inaccurate when adding 0.001 to a value possible solution round($num, 3); Test script: --------------- echo '<table>'; $ii =0; for($i =1; $i<= 10000; $i++) { echo '<tr>'; echo '<td>'; echo $ii; echo '</td>'; echo '</tr>'; $ii = $ii +0.001; } echo '</table>'; Expected result: ---------------- 1.459 1.46 1.461 1.462 1.463 1.464 1.465 1.466 ... 2.369 2.370 2.371 2.372 2.373 2.374 2.375 ... 3.278 3.279 3.280 3.281 Actual result: -------------- 1.459 1.46 1.4609999999999 1.4619999999999 1.4629999999999 1.4639999999999 1.4649999999999 1.4659999999999 ... 2.3689999999999 2.3699999999999 2.3709999999998 2.3719999999998 2.3729999999998 2.3739999999998 2.3749999999998 ... 3.2769999999998 3.2779999999998 3.2789999999997 3.2799999999997 and so on