[Python-Dev] Expert floats

Jewett, Jim J jim.jewett at eds.com
Tue Apr 6 10:29:10 EDT 2004


Ka-Ping Yee:

>    >>> 3.3
>    3.2999999999999998

> confused and frightened them, and continues to confuse and frighten
> almost everyone i teach. 

It bothered me when I first saw it (not in Python).

It was still better than trying to figure out why my code was doing
the wrong thing, when my math and logic were both clearly correct.  

To steal Simon Percivall's example, I assumed 2.20 - 1.20 == 1.00.
It didn't even occur to me to check something as obviously true as 
that -- until I had learned and remembered that floats were not 
decimals.

-jJ



More information about the Python-Dev mailing list