Message241636
| 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: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 |
|