Message241636
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. |
|
Date |
User |
Action |
Args |
2015-04-20 12:38:35 | wolma | set | recipients:
+ wolma, mark.dickinson |
2015-04-20 12:38:35 | wolma | set | messageid: <1429533515.2.0.0924003288171.issue23975@psf.upfronthosting.co.za> |
2015-04-20 12:38:35 | wolma | link | issue23975 messages |
2015-04-20 12:38:35 | wolma | create | |
|