Added more documentation on how mixed-mode arithmetic should be implemented. I
also noticed and fixed a bug in Rational's forward operators (they were
claiming all instances of numbers.Rational instead of just the concrete types).
diff --git a/Lib/numbers.py b/Lib/numbers.py
index 8e02203..e391abc 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -292,7 +292,13 @@
# Concrete implementation of Real's conversion to float.
def __float__(self):
- """float(self) = self.numerator / self.denominator"""
+ """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