MCPcopy Index your code
hub / github.com/python/cpython / to_integral_value

Method to_integral_value

Lib/_pydecimal.py:2663–2677  ·  view source on GitHub ↗

Rounds to the nearest integer, without raising inexact, rounded.

(self, rounding=None, context=None)

Source from the content-addressed store, hash-verified

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

Callers 6

_power_moduloMethod · 0.95
test_c_integralMethod · 0.95
to_integral_valueMethod · 0.45
innerFunction · 0.45
test_none_argsMethod · 0.45
test_named_parametersMethod · 0.45

Calls 4

_check_nansMethod · 0.95
_rescaleMethod · 0.95
getcontextFunction · 0.85
DecimalClass · 0.85

Tested by 3

test_c_integralMethod · 0.76
test_none_argsMethod · 0.36
test_named_parametersMethod · 0.36