From: daniel dot oconnor at gmail dot com Operating system: Irrelevant PHP version: 5.2.4 PHP Bug Type: Feature/Change Request Bug description: var_dump() should render more precise floats
Description: ------------ var_dump() does not show the actual value of floats; but rather performs rounding before rendering. This can lead to hard to decipher loss of precision bugs. If you then use var_dump() to try to compare output, you aren't going to find the *actual* values of the numbers you are comparing. For this reason, I'd like to ask var_dump() renders the complete representation of the number; where needed in scientific notation. Reproduce code: --------------- <?php function variance($a, $b) { return (double)100.00 - (double)(($a/$b) * 100.00); } var_dump(12.99); //12.99 var_dump(variance(87.01, 100.00)); //12.99 var_dump(variance(87.01, 100.00) - 12.99); //difference <-5.3290705182008E-15> Expected result: ---------------- ---------- php ---------- float(12.99) float(12.99) // should be 12.99 + -5.3290705182008E-15 float(-5.3290705182008E-15) Output completed (0 sec consumed) - Normal Termination Actual result: -------------- ---------- php ---------- float(12.99) float(12.99) float(-5.3290705182008E-15) Output completed (0 sec consumed) - Normal Termination -- Edit bug report at http://bugs.php.net/?id=42635&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42635&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42635&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42635&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42635&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42635&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42635&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42635&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42635&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42635&r=support Expected behavior: http://bugs.php.net/fix.php?id=42635&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42635&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42635&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42635&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42635&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42635&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42635&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42635&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42635&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42635&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42635&r=mysqlcfg