MCPcopy Index your code
hub / github.com/RustPython/RustPython / to_integral_value

Method to_integral_value

Lib/_pydecimal.py:2660–2674  ·  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

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

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