ID: 39262 Updated by: [EMAIL PROTECTED] Reported By: cjjer at hotmail dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: windows2k PHP Version: 5.1.X 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: ------------------------------------------------------------------------ [2006-10-26 08:48:03] cjjer at hotmail dot com [code] for($i=0.0; $i<1;){ echo intval(($i+0.10)*10.0).'<br/>'; $i=$i+0.1; } [/code] ------------------------------------------------------------------------ [2006-10-26 08:43:33] cjjer at hotmail dot com Description: ------------ intval function failed ;for intval((0.1+0.7)*10) not is 8 ,but 7. Reproduce code: --------------- 1 2 3 4 5 6 7 7 9 9 10 Expected result: ---------------- 1 2 3 4 5 6 7 8 9 9 10 Actual result: -------------- 1 2 3 4 5 6 7 7 9 9 10 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39262&edit=1
