This math scares me
tjreedy at udel.edu
Mon Mar 12 23:00:09 CET 2001
<costas at springmail.com> wrote in message
news:3aad4062.1290021 at News.CIS.DFN.DE...
> Ok, I can see maybe division having problems. But why does addition of
the two numbers below:
> give me this?
Neither 5.01, 5.54, nor 10.55 have exact binary representations. Floating
point arithmetic is always slightly approximate unless you only use
'binary' fractions like .5, .25, .125, .0625, etc and multiples.
Understanding and controlling such inexactness is a large part of the
discipline of numerical analysis.
> I hope its some setting that can take care of this. I am using Python
under Windows 98.
You can hide the inexactness by displaying results with % formats.
Terry J. Reedy
More information about the Python-list