Edit report at http://bugs.php.net/bug.php?id=54985&edit=1
ID: 54985 Updated by: cataphr...@php.net Reported by: jille at hexon dot cx Summary: round doesn't work with non-14 precision -Status: Assigned +Status: Bogus Type: Bug Package: *Math Functions Operating System: n/a PHP Version: 5.3.6 Assigned To: cataphract Block user comment: N Private report: N New Comment: This is a bogus report (.055 is not exactly representable, the closest is 7926335344172073*2^-57); r301991 did introduce a bug, but it's completely unrelated. Previous Comments: ------------------------------------------------------------------------ [2011-06-10 20:10:39] cataphr...@php.net Seems to have been introduced by the fix to bug #52550 (r301991). ------------------------------------------------------------------------ [2011-06-03 16:10:14] jille at hexon dot cx 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 this bug report at http://bugs.php.net/bug.php?id=54985&edit=1