ID: 47389 Updated by: j...@php.net Reported By: php at mycel dot nl -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Ubuntu PHP Version: 5.2.9RC2 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. If you would like to know more about "floats" and what IEEE 754 is, read this: http://docs.sun.com/source/806-3568/ncg_goldberg.html Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2009-02-14 20:57:41] php at mycel dot nl Description: ------------ With a for, if you count to 100, it will miscounts after a while. (with other computers it wil miscount earlier) Reproduce code: --------------- for ($i = 0; $i <= 800; $i += 0.01) { echo $i.'<br/>'; } Expected result: ---------------- 709.23 709.24 709.25 709.26 709.27 709.28 709.29 Actual result: -------------- 709.23 709.24 709.25 709.259999999 709.269999999 709.279999999 709.289999999 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47389&edit=1