Count Down to Zero

Steve Holden sholden at holdenweb.com
Fri Sep 22 16:58:11 EDT 2000


Oops.  In my last posting I dropped a few zeroes.  The number your
loop left was actually:

	0.000000000000000138777878078
not
	0.000000000138777878078

Still. what's five orders of magnitude between friends? :-)

regards
 Steve

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
> 
> --
> Curtis Jensen
> cjensen at bioeng.ucsd.edu
> http://www-bioeng.ucsd.edu/~cjensen/
> FAX (425) 740-1451

-- 
Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/




More information about the Python-list mailing list