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

Method to_integral_value

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

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

Callers 1

Calls 2

_convert_otherFunction · 0.85
to_integral_valueMethod · 0.45

Tested by 1