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

Method to_integral_value

Lib/_pydecimal.py:5563–5590  ·  view source on GitHub ↗

Rounds to an integer. When the operand has a negative exponent, the result is the same as using the quantize() operation using the given operand as the left-hand-operand, 1E+0 as the right-hand-operand, and the precision of the operand as the precision setting, excep

(self, a)

Source from the content-addressed store, hash-verified

5561 return a.to_integral_exact(context=self)
5562
5563 def to_integral_value(self, a):
5564 """Rounds to an integer.
5565
5566 When the operand has a negative exponent, the result is the same
5567 as using the quantize() operation using the given operand as the
5568 left-hand-operand, 1E+0 as the right-hand-operand, and the precision
5569 of the operand as the precision setting, except that no flags will
5570 be set. The rounding mode is taken from the context.
5571
5572 >>> ExtendedContext.to_integral_value(Decimal('2.1'))
5573 Decimal('2')
5574 >>> ExtendedContext.to_integral_value(Decimal('100'))
5575 Decimal('100')
5576 >>> ExtendedContext.to_integral_value(Decimal('100.0'))
5577 Decimal('100')
5578 >>> ExtendedContext.to_integral_value(Decimal('101.5'))
5579 Decimal('102')
5580 >>> ExtendedContext.to_integral_value(Decimal('-101.5'))
5581 Decimal('-102')
5582 >>> ExtendedContext.to_integral_value(Decimal('10E+5'))
5583 Decimal('1.0E+6')
5584 >>> ExtendedContext.to_integral_value(Decimal('7.89E+77'))
5585 Decimal('7.89E+77')
5586 >>> ExtendedContext.to_integral_value(Decimal('-Inf'))
5587 Decimal('-Infinity')
5588 """
5589 a = _convert_other(a, raiseit=True)
5590 return a.to_integral_value(context=self)
5591
5592 # the method name changed, but we provide also the old one, for compatibility
5593 to_integral = to_integral_value

Callers 1

Calls 2

_convert_otherFunction · 0.85
to_integral_valueMethod · 0.45

Tested by 1