Count Down to Zero

Curtis Jensen cjensen at bioeng.ucsd.edu
Mon Sep 25 13:08:16 EDT 2000


Curtis Jensen wrote:
> 
> How come Python can't count down to zero?  Was it written by ancient
> Romans or something?
> 
> Python 1.5.2 (#7, Apr 21 2000, 13:18:02) [C] on irix646
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> float(0)
> 0.0
> >>> float( '0' )
> 0.0
> >>> i = 1.0
> >>> while i >= 0.0:
> ...   print i
> ...   i = i - 0.1
> ...
> 1.0
> 0.9
> 0.8
> 0.7
> 0.6
> 0.5
> 0.4
> 0.3
> 0.2
> 0.1
> 1.38777878078e-16
> >>>
> 
> The last one should be 0.0
> 

Thanks Everyone. :)

-- 
Curtis Jensen
cjensen at bioeng.ucsd.edu
http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451



More information about the Python-list mailing list