I have the following code
$suma += round(1*43067.8000,2);
$suma += round(-1*18875.1800,2);
$suma += round(-1*15293.9700,2);
$suma += round(-1*8898.6500,2);
print $suma;
The output is 3.6379788070917E-12
Why the answer is not 0 if the number is rounded before the addition?
Answer
Round still returns a float. Because it is a float there might always be very small errors. In this case, this causes your answer to differ from 0.
No comments:
Post a Comment