From: guillaume dot loire at cnrs dot fr Operating system: Linux debian Squeeze PHP version: Irrelevant Package: Math related Bug Type: Bug Bug description:Calculation error with ceil
Description: ------------ Hello, I found a calculation error with ceil function. When doing a calculation such as this : ceil(8.80*1.00*100) it returns 881 instead of 880. While doing ceil(880) it returns (as it should) 880. I think this error occurs when running ceil function cumulative with calculation and not with a single number. I wrote a little script to identify if others numbers are impacted and i found theses ones when running it from 10 to 10000, but there may be other. Test script: --------------- <?php for ($i = 10; $i <= 10000; $i+=10) { $toto=ceil(($i/100*1.00)*100); if (preg_match( '/1$/',$toto)) { echo $toto."<br>"; } } ?> Expected result: ---------------- 110 220 440 490 830 880 930 980 1610 1660 1710 1760 1810 1860 1910 1960 2010 3220 3270 3320 3370 3420 3470 3520 3570 3620 3670 3720 3770 3820 3870 3920 3970 4020 4070 6440 6490 6540 6590 6640 6690 6740 6790 6840 6890 6940 6990 7040 7090 7140 7190 7240 7290 7340 7390 7440 7490 7540 7590 7640 7690 7740 7790 7840 7890 7940 7990 8040 8090 8140 8190 Actual result: -------------- 111 221 441 491 831 881 931 981 1611 1661 1711 1761 1811 1861 1911 1961 2011 3221 3271 3321 3371 3421 3471 3521 3571 3621 3671 3721 3771 3821 3871 3921 3971 4021 4071 6441 6491 6541 6591 6641 6691 6741 6791 6841 6891 6941 6991 7041 7091 7141 7191 7241 7291 7341 7391 7441 7491 7541 7591 7641 7691 7741 7791 7841 7891 7941 7991 8041 8091 8141 8191 -- Edit bug report at https://bugs.php.net/bug.php?id=64674&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64674&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64674&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64674&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64674&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64674&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64674&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64674&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64674&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64674&r=support Expected behavior: https://bugs.php.net/fix.php?id=64674&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64674&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64674&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64674&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64674&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64674&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64674&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64674&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64674&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64674&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64674&r=mysqlcfg