Octavian Râşniţă wrote:
It sounds like a limitation of perl because it makes the calculations at
a too low level and not correct the errors automaticly, and not a
limitation of computers in general, because PHP does it right, MS Excel
does it right, the Windows Calculator does it right, so it is not
something imposible to do automaticly.
PHP and MS Excel etc. don't do it right, but they make the choice for you.
For example: would you perceive rounding 0.505 to 0.50 as an error, as
surprising, or understand it?
In different contexts, the below two results can either be good or bad:
perl -wle'
print sprintf "%.2f", 0.505;
print sprintf "%.2f", 0.50499999999999999;
'
0.51
0.51
Rounding towards even minimizes the error whem summing rounded values.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/