From: Operating system: n/a PHP version: 5.3.6 Package: *Math Functions Bug Type: Bug Bug description:round doesn't work with non-14 precision
Description: ------------ Round() doesn't work right when the precision is set to e.g. 16. The last comment in #51701 also makes notice of this. (However it seems unrelated to that bugreport.) Bug #5500 states that you shouldn't set the precision higher than the data-type can hold. If that's still true I think we should add a warning when setting the precision too high instead of just accepting it and trying to work it out. _php_math_round in ext/standard/math.c cites: if ((precision_places = php_intlog10abs(value)) > 0) { precision_places = 14 - php_intlog10abs(value); } else { precision_places = 14; } and I guess 14 shouldn't be hardcoded there. Test script: --------------- php > ini_set('precision', 30); php > var_dump(round((5.5/100), 3)); Expected result: ---------------- float(0.055) Actual result: -------------- float(0.0550000000000000002775557561563) -- Edit bug report at http://bugs.php.net/bug.php?id=54985&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54985&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54985&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54985&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54985&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54985&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54985&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54985&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54985&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54985&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54985&r=support Expected behavior: http://bugs.php.net/fix.php?id=54985&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54985&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54985&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54985&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54985&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54985&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54985&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54985&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54985&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54985&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54985&r=mysqlcfg