From: sdibb at myway dot com Operating system: Linux PHP version: 5.0.1 PHP Bug Type: Math related Bug description: array_sum gives an incorrect total
Description: ------------ array_sum AND adding numbers seems to be returning the wrong total, where all the values are floats. It seems to be in every case that it's the last value that throws off the grand total. Tested with both v4.3.8 and v5.0.1 on different linux machines. Looks like a dupe of http://bugs.php.net/bug.php?id=6034 but not sure, since this doesn't use very large values for the numbers. Reproduce code: --------------- long example: http://wonkabar.org/array_sum.phps short example: php -r "print array_sum(array(149.96, 49.99, -20.00, -149.96, 0, -20.00, -9.99));" Expected result: ---------------- the correct calculated totals. Actual result: -------------- short example: 8.881784197E-15 # php -m [PHP Modules] bz2 ctype gmp mysql overload pcre pgsql posix session sqlite standard tokenizer xml zip zlib [Zend Modules] -- Edit bug report at http://bugs.php.net/?id=30199&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30199&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30199&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30199&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30199&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30199&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30199&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30199&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30199&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30199&r=support Expected behavior: http://bugs.php.net/fix.php?id=30199&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30199&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30199&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30199&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30199&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30199&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30199&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30199&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30199&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30199&r=mysqlcfg