If you want to do decimal arithmetic, use the decimal module which is
new in Python 2.4.

Python 2.4 (#1, Jan 22 2005, 20:45:18) 
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal as D
>>> D("1.0") + D("3.0") + D("4.6")
Decimal("8.6")
>>> 

when you write '4.6', you get a binary floating-point number which is
not equal to the decimal number 4.6.
>>> 4.6
4.5999999999999996
>>> 4.6 == D("4.6")
False

Jeff

Attachment: pgpTCJaVo6X1e.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to