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

Method add

Lib/_pydecimal.py:4131–4150  ·  view source on GitHub ↗

Return the sum of the two operands. >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) Decimal('19.00') >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) Decimal('1.02E+4') >>> ExtendedContext.add(1, Decimal(2)) Decimal('3') >>

(self, a, b)

Source from the content-addressed store, hash-verified

4129 return a.__abs__(context=self)
4130
4131 def add(self, a, b):
4132 """Return the sum of the two operands.
4133
4134 >>> ExtendedContext.add(Decimal('12'), Decimal('7.00'))
4135 Decimal('19.00')
4136 >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
4137 Decimal('1.02E+4')
4138 >>> ExtendedContext.add(1, Decimal(2))
4139 Decimal('3')
4140 >>> ExtendedContext.add(Decimal(8), 5)
4141 Decimal('13')
4142 >>> ExtendedContext.add(5, 5)
4143 Decimal('10')
4144 """
4145 a = _convert_other(a, raiseit=True)
4146 r = a.__add__(b, context=self)
4147 if r is NotImplemented:
4148 raise TypeError("Unable to convert %s to Decimal" % b)
4149 else:
4150 return r
4151
4152 def _apply(self, a):
4153 return str(a._fix(self))

Callers 1

test_addMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__add__Method · 0.45

Tested by 1

test_addMethod · 0.76