I can not guess the problem of representing and subtracting a floating point number But,
When you subtract these values ββwithout a round, you get the result ** 3578.455
And when you round it to two decimal places, round it with 3578.46 .
So php has a solution with this problem.
PHP_ROUND_HALF_UP Round val up to precision decimal places away from zero, when it is half way there. Making 1.5 into 2 and -1.5 into -2. PHP_ROUND_HALF_DOWN Round val down to precision decimal places towards zero, when it is half way there. Making 1.5 into 1 and -1.5 into -1. PHP_ROUND_HALF_EVEN Round val to precision decimal places towards the next even value. PHP_ROUND_HALF_ODD Round val to precision decimal places towards the next odd value.
These constants are provided with a round function as
echo round(100.675, 2, PHP_ROUND_HALF_UP); // 100.68 echo round(100.675, 2, PHP_ROUND_HALF_DOWN); // 100.67
So PHP_ROUND_HALF_DOWN Will be useful in your case
source share