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