123.3 + 0.1 is 123.3999999999 ?

Tony Meyer ta-meyer at ihug.co.nz
Thu May 15 19:38:14 EDT 2003


> > This isn't strictly true, of course.  A third (or any other rational
> > number) can be represented by a pair of numbers (numerator,
> > denominator) like 1 and 3.
> 
> I think you mean a pair of _integers_.  It's nitpicking, but 
> it's rather important nitpick :-).

Ah, that was hidden in the meaning of 'like'.  As in, 1 and 3 are
integers, so 'a pair of numbers that are integers' <wink>.

Actually, a rational number can be expressed as a pair of _rational_
numbers as well, although sooner or later you're going to have to use
only integers or run into infinity.  You can use a pair of complex
numbers as well, as long as the real/imaginary parts are also
integers/rationals.  In fact, for some numbers, you can even use
irrational pairs - one can be represented as PI/PI, for example.

If one was _implementing_ a rational class, of course, then yes,
integers are the way to go.  (Unless there's some wacky complex stuff
going on).

=Tony Meyer






More information about the Python-list mailing list