Edit report at http://bugs.php.net/bug.php?id=53549&edit=1
ID: 53549 Updated by: [email protected] Reported by: jeffreybolle at gmail dot com Summary: Rounding twice yields a different result than rounding once -Status: Open +Status: Bogus Type: Bug Package: Math related Operating System: ALL PHP Version: 5.3.4 Block user comment: N Private report: N 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: ------------------------------------------------------------------------ [2010-12-15 11:03:22] jeffreybolle at gmail dot com Description: ------------ Rounding a float once should result in the same value as rounding it more than once. Test script: --------------- <?php $float = -1.1368683772162E-13; var_dump(round($float, 2)); var_dump(round(round($float, 2), 2)); Expected result: ---------------- float(0) float(0) Actual result: -------------- float(-0) float(0) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53549&edit=1
