mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
e757005190
commit
349a78534b
1 changed files with 9 additions and 0 deletions
|
@ -1649,6 +1649,9 @@ class Decimal(_numbers.Real):
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
def __round__(self):
|
||||||
|
return self._round_down(0)
|
||||||
|
|
||||||
def _round_up(self, prec):
|
def _round_up(self, prec):
|
||||||
"""Rounds away from 0."""
|
"""Rounds away from 0."""
|
||||||
return -self._round_down(prec)
|
return -self._round_down(prec)
|
||||||
|
@ -1684,6 +1687,9 @@ class Decimal(_numbers.Real):
|
||||||
else:
|
else:
|
||||||
return -self._round_down(prec)
|
return -self._round_down(prec)
|
||||||
|
|
||||||
|
def __ceil__(self):
|
||||||
|
return self._round_ceiling(0)
|
||||||
|
|
||||||
def _round_floor(self, prec):
|
def _round_floor(self, prec):
|
||||||
"""Rounds down (not towards 0 if negative)"""
|
"""Rounds down (not towards 0 if negative)"""
|
||||||
if not self._sign:
|
if not self._sign:
|
||||||
|
@ -1691,6 +1697,9 @@ class Decimal(_numbers.Real):
|
||||||
else:
|
else:
|
||||||
return -self._round_down(prec)
|
return -self._round_down(prec)
|
||||||
|
|
||||||
|
def __floor__(self):
|
||||||
|
return self._round_floor(0)
|
||||||
|
|
||||||
def _round_05up(self, prec):
|
def _round_05up(self, prec):
|
||||||
"""Round down unless digit prec-1 is 0 or 5."""
|
"""Round down unless digit prec-1 is 0 or 5."""
|
||||||
if prec and self._int[prec-1] not in '05':
|
if prec and self._int[prec-1] not in '05':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue