[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues (original) (raw)

Raymond Hettinger python@rcn.com
Wed, 2 Oct 2002 23:13:16 -0400


From: "Greg Ewing" <greg@cosc.canterbury.ac.nz>

> The HP32SII calculator implements a useful rational model using > flags and a maximum denominator register. If the first flag is clear, > fractions are have denominators upto the maximum value. If only > the first flag is set, fractions always use the maximum denominator > as the denominator and are then reduced (i.e. if the max is 8, then > .5 is represented as 1/2 and .1 is represented as 1/8).

I can see that being useful when you're doing calculations with, e.g. measurements in 64ths of an inch and you don't care if anything smaller than that isn't quite exact. But I get the impression that the folks who want rationals in Python want them precisely because they're always exact. If you couldn't rely on them to always be exact, it would defeat the purpose.

For that, I propose maxdenom=None to let the rationals grow without bound.

Raymond Hettinger