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

Method minus

Lib/_pydecimal.py:4907–4922  ·  view source on GitHub ↗

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

(self, a)

Source from the content-addressed store, hash-verified

4905 return a.min_mag(b, context=self)
4906
4907 def minus(self, a):
4908 """Minus corresponds to unary prefix minus in Python.
4909
4910 The operation is evaluated using the same rules as subtract; the
4911 operation minus(a) is calculated as subtract('0', a) where the '0'
4912 has the same exponent as the operand.
4913
4914 >>> ExtendedContext.minus(Decimal('1.3'))
4915 Decimal('-1.3')
4916 >>> ExtendedContext.minus(Decimal('-1.3'))
4917 Decimal('1.3')
4918 >>> ExtendedContext.minus(1)
4919 Decimal('-1')
4920 """
4921 a = _convert_other(a, raiseit=True)
4922 return a.__neg__(context=self)
4923
4924 def multiply(self, a, b):
4925 """multiply multiplies two operands.

Callers 1

test_minusMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__neg__Method · 0.45

Tested by 1

test_minusMethod · 0.76