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

Method to_integral_exact

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

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

Callers 1

Calls 2

_convert_otherFunction · 0.85
to_integral_exactMethod · 0.45

Tested by 1