From: infohata at firmos dot net Operating system: Linux PHP version: 4.3.2 PHP Bug Type: *Math Functions Bug description: round() does 5.045 to 5.04 instrad of 5.05
Description: ------------ I am using a webhosting service of bbdsoft (www.firmos.net) so I don't know exact OS and configuration of PHP.INI, but this bug is independent of any config or OS, it's about round() function - it has a big bug rounding floats!! All the details and what's have to be is written below in the source code and it's comments:) Well, I saw other reports, and I think YOU SHOULD FIX THIS IN ANY CASE AND AS FAST AS POSSIBLE!!! Reproduce code: --------------- // at the start of the return code these variables has values: $skerd_svoris = 1; $rows_kriu_kain00[0] = 5; $rows_kriu_kkoef[0] = 0.9; // return code: return sprintf("%1.2f", round($skerd_svoris*round($rows_kriu_kain00[0]*(1+($rows_kriu_kkoef[0]/100)), 2), 2)); // if the code is changed to: // return sprintf("%1.2f", round($skerd_svoris*round($rows_kriu_kain00[0]*(1+($rows_kriu_kkoef[0]/100))+0.000001, 2), 2)); // all goes OK; so the problem is that if the number is 5.045, rounded it will be 5.04, but if it is 5.045001 - rounded it will be 5.05. I think You understood what I want to say:) Expected result: ---------------- 5.05 Actual result: -------------- 5.04 -- Edit bug report at http://bugs.php.net/?id=24142&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24142&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24142&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24142&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24142&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24142&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24142&r=support Expected behavior: http://bugs.php.net/fix.php?id=24142&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24142&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24142&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24142&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24142&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24142&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24142&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24142&r=gnused