Count Down to Zero

Grant Griffin g2 at seebelow.org
Sat Sep 23 04:28:29 EDT 2000


Curtis Jensen wrote:
> 
> How come Python can't count down to zero?  Was it written by ancient
> Romans or something?

If Python was written by ancient Romans, we wouldn't be fussing about
its licence now, because its copyright would long since have expired.
<wink>

> 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

If you've had a chance to read some of the other responses to this
thread, you probably can explain the following:

>>> i=1.0
>>> while i >= 0.0:
...    print i
...    i = i - 0.125
...
1.0
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0.0

when-in-rome,-think-like-a-computer-<wink>-ly y'rs,

=g2 
-- 
_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation	      http://www.iowegian.com



More information about the Python-list mailing list