[issue1682] Move Demo/classes/Rat.py to Lib/rational.py and fix it up.

Raymond Hettinger report at bugs.python.org
Fri Jan 11 22:26:09 CET 2008


Raymond Hettinger added the comment:

> If the consensus is that Decimal should not implement Real,
> I'll reply to that thread and withdraw the patch.

Thanks. That would be nice.


> Raymond, do you want me to add Decimal.__init__(Rational)
> in this patch

How about focusing on the rational module and when you've done, I'll
adapt the Decimal constructor to accept a rational input.


> I don't understand the comment about scaling down long integers. 

My understanding is that you're going to let numerators and denominators
grow arbitrarily large.  When they get over several hundred digits each,
you will have to scale the down before converting to a float.  For
example when numerator=long('2'*400+'7') and
denominator=long('3'*400+'1'), the long-->float conversion will
overflow, so it is necessary to first scale-down the two before
computing the ratio: scale=325;
float_ratio=float(numerator>>scale)/float(denominator>>scale)

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1682>
__________________________________


More information about the Python-bugs-list mailing list