This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wolma
Recipients mark.dickinson, wolma
Date 2015-04-20.12:38:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429533515.2.0.0924003288171.issue23975@psf.upfronthosting.co.za>
In-reply-to
Content
Good point.

If the numbers ABC guaranteed numerator and denominator to be Integral numbers, this could be solved by:

return float(int(self.numerator) / int(self.denominator))

but since both could be Rationals again that does not seem to be an option either.
What could be done is trying to multiply out the numerator and denominator pair until both *are* Integrals, like:

num = self.numerator
den = self.denominator
while not (isinstance(num, Integral) and isinstance(den, Integral)):
    num = num.numerator * den.denominator
    den = den.numerator * num.denominator
return float(int(num) / int(den))

Clearly that's more complicated, but, more importantly, has the disadvantage that the loop will run forever if the final numerator or denominator is not registered correctly in the numeric tower.
So some kind of check for this situation would be required, but I do not have an idea right now what that should look like.
History
Date User Action Args
2015-04-20 12:38:35wolmasetrecipients: + wolma, mark.dickinson
2015-04-20 12:38:35wolmasetmessageid: <1429533515.2.0.0924003288171.issue23975@psf.upfronthosting.co.za>
2015-04-20 12:38:35wolmalinkissue23975 messages
2015-04-20 12:38:35wolmacreate