why do I get this behavior from a while loop?

Paul Rudin paul.nospam at rudin.co.uk
Fri Nov 27 17:24:39 CET 2009

"S. Chris Colbert" <sccolbert at gmail.com> writes:

>    ....:     print t    

Try replacing with: print  "%0.20f" % t

The thing you're missing is that floating point arithmetic isn't (in
general) exact - but when it's printed it's rounded.

More information about the Python-list mailing list