summaryrefslogtreecommitdiffstats
path: root/Lib/numbers.py
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2008-01-31 07:44:11 (GMT)
committerJeffrey Yasskin <jyasskin@gmail.com>2008-01-31 07:44:11 (GMT)
commitb23dea6adb7eaf3f415e05b129afa01fa1c4dd5c (patch)
treecbf4e47655cc1cc341b384d213a0fceb865876ad /Lib/numbers.py
parente973c61238807dcf4ccedc18a99db8f478c422c7 (diff)
downloadcpython-b23dea6adb7eaf3f415e05b129afa01fa1c4dd5c.zip
cpython-b23dea6adb7eaf3f415e05b129afa01fa1c4dd5c.tar.gz
cpython-b23dea6adb7eaf3f415e05b129afa01fa1c4dd5c.tar.bz2
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).
Diffstat (limited to 'Lib/numbers.py')
-rw-r--r--Lib/numbers.py8
1 files changed, 7 insertions, 1 deletions
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 @@ class Rational(Real, Exact):
# 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