[Python-Dev] Expert floats

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Apr 6 21:58:33 EDT 2004

Andrew Koenig <ark-mlist at att.net>:

> The reason is that the first example does arithmetic, and it is easy
> to explain that floating-point arithmetic is not completely accurate.

Then how would you explain this to them:

>>> 1.1 < 1.1000000000000001

There's no arithmetic being done there.

And if you're thinking of something like "floats don't have that
many digits of precision", you then need to explain

>>> 1.2 < 1.2000000000000001

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list