[Detroit-pm] Strange problem with simple math in perl
Craig Maloney
craig at decafbad.net
Thu Nov 12 17:59:02 PST 2009
On Thu, 2009-11-12 at 17:18 -0500, Jim McQuillan wrote:
> I know it's not perl's fault. In fact, I tried the same thing in python:
>
> #!/usr/bin/python
>
> new_bal = 123.00 - 69.63 - 53.37;
>
> print new_bal;
>
> Not surprisingly, I get the same result as the perl example I showed
> earlier.
Actually, Python has a datatype specifically for this sort of
work-around:
>>> from decimal import *
>>> Decimal('.01') + Decimal('.01') + Decimal('.02')
Decimal('0.04')
--
--------------------------------------------------------------------
Craig Maloney (craig at decafbad.net) http://decafbad.net
"Work hard, rock hard, eat hard, sleep hard, grow big,
wear glasses if you need 'em." -- The Webb Wilder Credo
More information about the Detroit-pm
mailing list