Edit report at https://bugs.php.net/bug.php?id=60557&edit=1
ID: 60557 Comment by: anon at anon dot anon Reported by: vividy163 at hotmail dot com Summary: ceil function bug Status: Open Type: Bug Package: Math related Operating System: Linux PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: (And if you need a solution for the more general case, consider subtracting a tiny value just before calling ceil:) echo ceil((12000*(7/100)) - 1e-8); // outputs: 840 Previous Comments: ------------------------------------------------------------------------ [2011-12-20 00:55:27] anon at anon dot anon Ceil is correct. Due to the underlying limitations of the floating point math, 7/100 is not a fraction which can be exactly represented, so the CPU chooses the closest possible value, and after multiplying the result is: 840.0000000000001136868377216160297393798828125 All programming languages implementing IEEE 754 (see: https://en.wikipedia.org/wiki/IEEE_754-1985 ) (which is most of them) will give 841 for this computation. In this specific case, just do the multiplication first (remove the extra brackets): echo ceil(12000*7/100); // outputs: 840 ------------------------------------------------------------------------ [2011-12-19 03:38:37] vividy163 at hotmail dot com Description: ------------ <?php echo ceil(12000*(7/100)); ?> it give me result 841. Test script: --------------- <?php echo ceil(12000*(7/100)); ?> it give me result 841. Expected result: ---------------- 840 Actual result: -------------- 841 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60557&edit=1