rounding - Loss of significance php round -
this question has answer here:
- php - floating number precision 9 answers
i have 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 3.6379788070917e-12
why answer not 0 if number rounded before addition?
round still returns float. because float there might small errors. in case, causes answer differ 0.
Comments
Post a Comment