monetary applications [was: Python GUI app to impress the bos s?]
magnus at thinkware.se
Fri Sep 20 08:46:47 EDT 2002
Paul Rubin wrote:
> I'm finding it hard to imagine how any real-world financial
> calculation using IEEE doubles could be off by as much as a penny.
Apart from the rounding problems etc that
the Decimal FAQ describes, I've seen people
getting into trouble when they compare floats
for equality. I've seen that several times
over the years.
In one system it worked well for years, until
the application was ported from VMS to HP-UX.
It would probably have worked on HP-UX as well,
but values calculated on one platform and stored
in the database didn't match values calculated
on the other.
There is always a risk for problems with cancellation
errors, but unless the subtracted values are equal
in the decimal representation and different in the
floating point representation, it will still be a
problem in a decimal representaion. But with a flexible
system for decimal representation, you can adjust
your accuracy to the present needs. With floats the
precision is the same regardless of our needs.
More information about the Python-list