Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 349a785

Browse files
committed
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.
1 parent e757005 commit 349a785

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/decimal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,9 @@ def _round_down(self, prec):
16491649
else:
16501650
return -1
16511651

1652+
def __round__(self):
1653+
return self._round_down(0)
1654+
16521655
def _round_up(self, prec):
16531656
"""Rounds away from 0."""
16541657
return -self._round_down(prec)
@@ -1684,13 +1687,19 @@ def _round_ceiling(self, prec):
16841687
else:
16851688
return -self._round_down(prec)
16861689

1690+
def __ceil__(self):
1691+
return self._round_ceiling(0)
1692+
16871693
def _round_floor(self, prec):
16881694
"""Rounds down (not towards 0 if negative)"""
16891695
if not self._sign:
16901696
return self._round_down(prec)
16911697
else:
16921698
return -self._round_down(prec)
16931699

1700+
def __floor__(self):
1701+
return self._round_floor(0)
1702+
16941703
def _round_05up(self, prec):
16951704
"""Round down unless digit prec-1 is 0 or 5."""
16961705
if prec and self._int[prec-1] not in '05':

0 commit comments

Comments
 (0)