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

Method plus

Lib/_pydecimal.py:5105–5120  ·  view source on GitHub ↗

Plus corresponds to unary prefix plus in Python. The operation is evaluated using the same rules as add; the operation plus(a) is calculated as add('0', a) where the '0' has the same exponent as the operand. >>> ExtendedContext.plus(Decimal('1.3')) Decimal('

(self, a)

Source from the content-addressed store, hash-verified

5103 return a.number_class(context=self)
5104
5105 def plus(self, a):
5106 """Plus corresponds to unary prefix plus in Python.
5107
5108 The operation is evaluated using the same rules as add; the
5109 operation plus(a) is calculated as add('0', a) where the '0'
5110 has the same exponent as the operand.
5111
5112 >>> ExtendedContext.plus(Decimal('1.3'))
5113 Decimal('1.3')
5114 >>> ExtendedContext.plus(Decimal('-1.3'))
5115 Decimal('-1.3')
5116 >>> ExtendedContext.plus(-1)
5117 Decimal('-1')
5118 """
5119 a = _convert_other(a, raiseit=True)
5120 return a.__pos__(context=self)
5121
5122 def power(self, a, b, modulo=None):
5123 """Raises a to the power of b, to modulo if given.

Callers 1

test_plusMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__pos__Method · 0.45

Tested by 1

test_plusMethod · 0.76