Floating point errors?

John W. Baxter jwbaxter at olympus.net
Fri May 11 11:33:48 EDT 2001


In article <mailman.989545217.22380.python-list at python.org>, Tim Peters
<tim.one at home.com> wrote:

> Harrumph.  Of course they're exact!  Selling them as some sort of fuzzy
> mystery is what keeps people confused about them 50 years after they should
> have learned better.

Yes, but they only exactly represent a few of the many possible values. 
And our friend 3.0/10.0 isn't one of them, when the floating point is
in binary.  25.0 / 100.0 "happens" to be one which is exactly
represented.  Of course it doesn't "happen"...one quarter is a nice
fraction in binary.

Murphy's law suggests that the particular value which needs to be
exactly represented to keep the boiler from exploding can't be.  ;-)

  --John



More information about the Python-list mailing list