ID: 46272 Updated by: [EMAIL PROTECTED] Reported By: chris at corecoding dot com -Status: Feedback +Status: Bogus Bug Type: Math related Operating System: Multiple: Debian and Mac OS X PHP Version: 5.2.6 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: ------------------------------------------------------------------------ [2008-10-10 18:41:18] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2008-10-10 18:39:23] chris at corecoding dot com Description: ------------ Both results should be 0. They are not! Reproduce code: --------------- $total = 2291.45; $paid = 2453.425; $tax = 161.975; echo (($total - $paid) + $tax) . "\n"; # -3.69482222595E-13 echo (($total + $tax) - $paid) . "\n"; -4.54747350886E-13 Expected result: ---------------- 0! Actual result: -------------- -3.69482222595E-13 and -4.54747350886E-13 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46272&edit=1