mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
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).
This commit is contained in:
parent
e973c61238
commit
b23dea6adb
3 changed files with 222 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue