ID:               28542
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tny at eyefi dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Variables related
 Operating System: Linix / BSDs
 PHP Version:      4.3.6
 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.
 
Thank you for your interest in PHP.

.


Previous Comments:
------------------------------------------------------------------------

[2004-05-27 15:01:29] tny at eyefi dot nl

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28542&edit=1

Reply via email to