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

Method to_integral_exact

Lib/_pydecimal.py:5530–5558  ·  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; Inexa

(self, a)

Source from the content-addressed store, hash-verified

5528 return a.__str__(context=self)
5529
5530 def to_integral_exact(self, a):
5531 """Rounds to an integer.
5532
5533 When the operand has a negative exponent, the result is the same
5534 as using the quantize() operation using the given operand as the
5535 left-hand-operand, 1E+0 as the right-hand-operand, and the precision
5536 of the operand as the precision setting; Inexact and Rounded flags
5537 are allowed in this operation. The rounding mode is taken from the
5538 context.
5539
5540 >>> ExtendedContext.to_integral_exact(Decimal('2.1'))
5541 Decimal('2')
5542 >>> ExtendedContext.to_integral_exact(Decimal('100'))
5543 Decimal('100')
5544 >>> ExtendedContext.to_integral_exact(Decimal('100.0'))
5545 Decimal('100')
5546 >>> ExtendedContext.to_integral_exact(Decimal('101.5'))
5547 Decimal('102')
5548 >>> ExtendedContext.to_integral_exact(Decimal('-101.5'))
5549 Decimal('-102')
5550 >>> ExtendedContext.to_integral_exact(Decimal('10E+5'))
5551 Decimal('1.0E+6')
5552 >>> ExtendedContext.to_integral_exact(Decimal('7.89E+77'))
5553 Decimal('7.89E+77')
5554 >>> ExtendedContext.to_integral_exact(Decimal('-Inf'))
5555 Decimal('-Infinity')
5556 """
5557 a = _convert_other(a, raiseit=True)
5558 return a.to_integral_exact(context=self)
5559
5560 def to_integral_value(self, a):
5561 """Rounds to an integer.

Callers 1

Calls 2

_convert_otherFunction · 0.85
to_integral_exactMethod · 0.45

Tested by 1