Really basic problem

Diez B. Roggisch deets at
Mon Oct 8 18:22:04 CEST 2007

Zentrader wrote:

> You can use Python's decimal class if floating point arithmetic is not
> exact enough

This is a misleading statement. While it's true that decimal can be more
precise in the sense that smaller fractions are representable, the
underlying problem of certain values not being representable properly &
leading to rounding errors still exists:

>>> import decimal
>>> d = decimal.Decimal
>>> d("1") / d("3")
>>> otrd = d("1") / d("3")
>>> otrd * 3
>>> otrd * d("3")


More information about the Python-list mailing list