This math scares me

Louis Luangkesorn lluang at northwestern.edu
Mon Mar 12 17:36:33 EST 2001


In addition to the comments you have gotten regarding floating point
arithmetic being inexact, try not to give those final digits in your
answer to anyone or do calculations that rely on those last digits. So if
you ever print this out, if you use the formatted output [i.e. print("
%6.4f" % (x))] that last bit will not appear, so you would be reasonably
safe.

Louis

costas at springmail.com wrote:

> Ok, I can see maybe division having problems. But why does addition of
> the two numbers below:
>
> 5.01+5.54
>
> give me this?
>
> 10.550000000000001
>
> I hope its some setting that can take care of this. I am using Python
> under Windows 98.
>
> TIA
>
> Costas

--
K Louis Luangkesorn
lluang at northwestern.edu  http://pubweb.nwu.edu/~kll560  PGP:0xF3E2D362
Whatsoever things are true, ... honest, ... just, ... pure, ... lovely,
... of good report; if there be any virtue, and if there be any praise,
think on these things.- motto - Northwestern University




More information about the Python-list mailing list