ID: 40304 Updated by: [EMAIL PROTECTED] Reported By: tjouanne at hotmail dot com -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Linux and windows PHP Version: 4.4.4 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: ------------------------------------------------------------------------ [2007-02-01 10:02:13] tjouanne at hotmail dot com Description: ------------ round number with round() function give strange result: 9.815,609.815,4690.815,14609.815,6.735,56.735,1056.735,11056.735 produce 9.82 609.82 4609.81 14609.82 6.74 56.74 1056.73 11056.74 Why it's become 81 or 73 instead of 82 or 74 Reproduce code: --------------- <? echo (round("9.815", 2)."<BR>"); echo (round("609.815", 2)."<BR>"); echo (round("4609.815", 2)."<BR>"); echo (round("14609.815", 2)."<BR>"); echo (round("6.735", 2)."<BR>"); echo (round("56.735", 2)."<BR>"); echo (round("1056.735", 2)."<BR>"); echo (round("11056.735", 2)."<BR>"); ?> Expected result: ---------------- 9.82 609.82 4609.82 14609.82 6.74 56.74 1056.74 11056.74 Actual result: -------------- 9.82 609.82 4609.81 14609.82 6.74 56.74 1056.73 11056.74 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40304&edit=1