[Detroit-pm] Strange problem with simple math in perl
Jim McQuillan
jam at McQuil.com
Thu Nov 12 07:34:35 PST 2009
Hey guys,
I'm having an issue with doing simple arithmetic in perl.
I suspect it's a floating-point issue.
here's the code:
==================================================
#!/usr/bin/perl -w
use strict;
my $new_bal = 123.00
- 69.63
- 53.37;
print("new_bal: $new_bal\n");
==================================================
The result I get is:
new_bal: 7.105427357601e-15
That's awfully close to the right answer, but I'm depending on perl to
be useful for calculating account balances.
Any ideas?
Thanks,
Jim McQuillan
jam at Avairis.com
More information about the Detroit-pm
mailing list