why do I get this behavior from a while loop?
Tim Wintle
tim.wintle at teamrubber.com
Fri Nov 27 11:35:19 EST 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:
<snip>
> I would think that second loop should terminate at 9.9, no?
>
> I am missing something fundamental?
Floating points variables ...
http://en.wikipedia.org/wiki/Floating_point
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
Tim
More information about the Python-list
mailing list