Rounds to the nearest integer, without raising inexact, rounded.
(self, rounding=None, context=None)
| 2661 | return ans |
| 2662 | |
| 2663 | def to_integral_value(self, rounding=None, context=None): |
| 2664 | """Rounds to the nearest integer, without raising inexact, rounded.""" |
| 2665 | if context is None: |
| 2666 | context = getcontext() |
| 2667 | if rounding is None: |
| 2668 | rounding = context.rounding |
| 2669 | if self._is_special: |
| 2670 | ans = self._check_nans(context=context) |
| 2671 | if ans: |
| 2672 | return ans |
| 2673 | return Decimal(self) |
| 2674 | if self._exp >= 0: |
| 2675 | return Decimal(self) |
| 2676 | else: |
| 2677 | return self._rescale(0, rounding) |
| 2678 | |
| 2679 | # the method name changed, but we provide also the old one, for compatibility |
| 2680 | to_integral = to_integral_value |