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

Method abs

Lib/_pydecimal.py:4110–4129  ·  view source on GitHub ↗

Returns the absolute value of the operand. If the operand is negative, the result is the same as using the minus operation on the operand. Otherwise, the result is the same as using the plus operation on the operand. >>> ExtendedContext.abs(Decimal('2.1'))

(self, a)

Source from the content-addressed store, hash-verified

4108
4109 # Methods
4110 def abs(self, a):
4111 """Returns the absolute value of the operand.
4112
4113 If the operand is negative, the result is the same as using the minus
4114 operation on the operand. Otherwise, the result is the same as using
4115 the plus operation on the operand.
4116
4117 >>> ExtendedContext.abs(Decimal('2.1'))
4118 Decimal('2.1')
4119 >>> ExtendedContext.abs(Decimal('-100'))
4120 Decimal('100')
4121 >>> ExtendedContext.abs(Decimal('101.5'))
4122 Decimal('101.5')
4123 >>> ExtendedContext.abs(Decimal('-101.5'))
4124 Decimal('101.5')
4125 >>> ExtendedContext.abs(-1)
4126 Decimal('1')
4127 """
4128 a = _convert_other(a, raiseit=True)
4129 return a.__abs__(context=self)
4130
4131 def add(self, a, b):
4132 """Return the sum of the two operands.

Callers 15

test_absMethod · 0.95
addMethod · 0.80
arcToMethod · 0.80
arcMethod · 0.80
MuFunction · 0.80
updateMethod · 0.80
_hashKeyMethod · 0.80
arcMethod · 0.80
_initMethod · 0.80
ZcFunction · 0.80
d3.min.jsFile · 0.80
MFunction · 0.80

Calls 2

_convert_otherFunction · 0.85
__abs__Method · 0.45

Tested by 2

test_absMethod · 0.76
test_absMethod · 0.64