ID: 27138 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Math related PHP Version: 5CVS-2004-02-03 (dev) 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-02-03 21:48:58] [EMAIL PROTECTED] Description: ------------ I saw this in a manual note. I don't know if it's really a problem, but others have agreed it's a bug, so... Only when using the floats 0.1 and 0.7 and multiplying by a number large enough to bring the product of the two floats' sums above 1 does a strange evaluation become apparent. Reproduce code: --------------- echo (int)((0.1 + 0.7) * 10); echo intval((0.1 + 0.7) * 10); echo (int)((0.1 + 0.7) * 20); echo (int)((0.1 + 0.8) * 20); echo (int)((0.1 + 0.8) * 10); Expected result: ---------------- 8 8 16 18 9 Actual result: -------------- 7 7 15 18 9 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27138&edit=1