|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-05-27 15:14 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 23:00:01 2025 UTC |
Description: ------------ When adding a float value to a variable (starting with a negative value) in a loop the result that should be zero (0) is nearly zero, but not exact zero. Reproduce code: --------------- <?php for ($i = -1.0; $i <= 1.0; $i += 0.1) { echo $i . "\n"; } ?> Expected result: ---------------- -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Actual result: -------------- -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 -1.38777878078E-16 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1