[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues
Greg Ewing
greg@cosc.canterbury.ac.nz
Thu, 03 Oct 2002 15:07:19 +1200 (NZST)
Raymond Hettinger <python@rcn.com>:
> 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.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+