why do I get this behavior from a while loop?

Tim Wintle tim.wintle at teamrubber.com
Fri Nov 27 17:35:19 CET 2009

On Fri, 2009-11-27 at 17:06 +0100, S. Chris Colbert wrote:
> This seems strange to me, but perhaps I am just missing something:
> I would think that second loop should terminate at 9.9, no? 
> I am missing something fundamental?

Floating points variables ...

0.1 isn't represented internally, so you haven't actually reached 10. -
try comparing that "10." (as it's printed) with 10.0 i.e.
     print (t == 10.)

you'll get False - even though they print the same


More information about the Python-list mailing list