From: Operating system: Linux PHP version: 5.2.17 Package: Unknown/Other Function Bug Type: Bug Bug description:Rounding error
Description: ------------ PHP 5.2.13 & 5.2.17 both have this weird errors in rounding function. This happens quite often, I can supply other numbers as well. Test script: --------------- <?php echo " 1.505: " . round(1.505, 2) . "\n"; echo " 11.505: " . round(11.505, 2) . "\n"; echo " 111.505: " . round(111.505, 2) . "\n"; echo " 111.505: " . round(1111.505, 2) . "\n"; echo " 1111.505: " . round(11111.505, 2) . "\n"; echo " 11111.505: " . round(111111.505, 2) . "\n"; echo " 111111.505: " . round(1111111.505, 2) . "\n"; echo " 1111111.505: " . round(11111111.505, 2) . "\n"; echo "11111111.505: " . round(111111111.505, 2) . "\n"; Expected result: ---------------- 1.505: 1.51 11.505: 11.51 111.505: 111.51 111.505: 1111.51 1111.505: 11111.51 11111.505: 111111.51 111111.505: 1111111.51 1111111.505: 11111111.51 11111111.505: 111111111.51 Actual result: -------------- 1.505: 1.51 11.505: 11.51 111.505: 111.51 111.505: 1111.51 1111.505: 11111.51 11111.505: 111111.51 111111.505: 1111111.5 1111111.505: 11111111.51 11111111.505: 111111111.51 -- Edit bug report at http://bugs.php.net/bug.php?id=53949&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53949&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53949&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53949&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53949&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53949&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53949&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53949&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53949&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53949&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53949&r=support Expected behavior: http://bugs.php.net/fix.php?id=53949&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53949&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53949&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53949&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53949&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53949&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53949&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53949&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53949&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53949&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53949&r=mysqlcfg