summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-05-04 00:00:19 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-05-04 00:00:19 (GMT)
commit349a78534bc21d643aa2b454dc09b3158c65e0b5 (patch)
tree47238fe5f41750c4d3b4dc3a1fe72e5b63b19016
parente757005190abe713daf1f2d40ed6afe8d8ee5b0c (diff)
downloadcpython-349a78534bc21d643aa2b454dc09b3158c65e0b5.zip
cpython-349a78534bc21d643aa2b454dc09b3158c65e0b5.tar.gz
cpython-349a78534bc21d643aa2b454dc09b3158c65e0b5.tar.bz2
Revert changes in 62669, since they caused test failures.
__floor__, __ceil__ and __round__ are still wrong, but they need to be replaced with something rather than just removed.
-rw-r--r--Lib/decimal.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 96d4b3e..a2e7fa4 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -1649,6 +1649,9 @@ class Decimal(_numbers.Real):
else:
return -1
+ def __round__(self):
+ return self._round_down(0)
+
def _round_up(self, prec):
"""Rounds away from 0."""
return -self._round_down(prec)
@@ -1684,6 +1687,9 @@ class Decimal(_numbers.Real):
else:
return -self._round_down(prec)
+ def __ceil__(self):
+ return self._round_ceiling(0)
+
def _round_floor(self, prec):
"""Rounds down (not towards 0 if negative)"""
if not self._sign:
@@ -1691,6 +1697,9 @@ class Decimal(_numbers.Real):
else:
return -self._round_down(prec)
+ def __floor__(self):
+ return self._round_floor(0)
+
def _round_05up(self, prec):
"""Round down unless digit prec-1 is 0 or 5."""
if prec and self._int[prec-1] not in '05':