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

Andrew Koenig ark@research.att.com
02 Oct 2002 21:17:30 -0400


By the way, has anyone considered the idea of making operations on rationals faster by never storing any trailing zeroes in the numerator or denominator? Instead, strip them and store the (signed) difference between the number of zeroes you've stripped from the numerator and the number you've stripped from the denominator.

In other words, instead of storing (num, denom) and having the number be the (exact) value of num/demon, store (num, denom, exp) and have the number be the (exact) value of (2**exp)*num/denom.

-- Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark