On 2010-09-01 22:46, Jim wrote:
Can anyone comment how they handle floating point precision situations
like this?
[...]
Note the lack of precision adding these simple numbers which do not have
a large number of digits to the right of the decimal.
If the line:
$total = sprintf("%.2f", $total);
would produce 0.00 rather than -0.00 I could live with this.
You could work in cents, so calculate with integers.
But with division, you would get into the same zone again.
Unless you accept rounding to integer there.
Also try bigrat.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/