123.3 + 0.1 is 123.3999999999 ?

A. Lloyd Flanagan alloydflanagan at attbi.com
Tue Jun 3 10:33:17 EDT 2003


Erik Max Francis <max at alcyone.com> wrote in message news:<3EDC5DBE.83E93BA9 at alcyone.com>...
> Grant Edwards wrote:
> 
> > In article <3EDC1074.CA05EC23 at alcyone.com>, Erik Max Francis wrote:
> >
> > > I suspect he's being facetious, since 0.999... = 1.
> > 
> > Right.  But it's never _stored_ as an infinite number of nines.  Nor
> > could
> > it be.
> 
> Of course not, hence the facetiousness.

Well, you can't store an infinite sequence, but you can store the
concept of an infinite number of nines:

def get_one():
    yield '0'
    yield '.'
    while 1:
        yield '9'

Exercise for the reader:  write a program to prove that get_one()
equals one.




More information about the Python-list mailing list