[Python-Dev] PEP239 (Rational Numbers) Reference Implementation and new issues

Christopher A. Craig python-pep at ccraig.org
Thu Oct 3 09:20:27 EDT 2002


"Eric S. Raymond" <esr at thyrsus.com> writes:

> APL faced this problem twenty-five years ago.  I like its solution; 
> a `fuzz' variable defining the close-enough-for-equality range.

For what it's worth, the current implementation is nothing this
complicated.  Like every other numeric operation, compares of
rationals with floats coerce to floats.  So as a result
rational(x)==float(x) iff float(rational(x))==float(x).

That is, of course, much more permissive than if we coerced the other
way and had rational(x)==float(x) iff rational(x)==rational(float(x)).

-- 
Christopher A. Craig <python-pep at ccraig.org>
"You could shoot Microsoft Office off the planet and this country would
 run better. You would see everyone standing around saying, 'I've got
 so much time now.' "  Scott McNealy (CEO of Sun)




More information about the Python-list mailing list