Message 241270 - Python tracker (original) (raw)
numbers.Rational defines float like this:
def float(self): """float(self) = self.numerator / self.denominator
It's important that this conversion use the integer's "true"
division rather than casting one side to float before dividing
so that ratios of huge integers convert without overflowing.
"""
return self.numerator / self.denominator
This assumes that division of two Integral numbers returns a float, which the numbers ABC does not enforce in any way. IMO, the only logical assumption is that division of any two Integral or Rational numbers gives a Real, for which the ABC guarantees a float method in turn. So I think Rational.float should
return float(self.numerator / self.denominator)