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

Method subtract

Lib/_pydecimal.py:5474–5495  ·  view source on GitHub ↗

Return the difference between the two operands. >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) Decimal('0.23') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) Decimal('0.00') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2

(self, a, b)

Source from the content-addressed store, hash-verified

5472 return a.sqrt(context=self)
5473
5474 def subtract(self, a, b):
5475 """Return the difference between the two operands.
5476
5477 >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
5478 Decimal('0.23')
5479 >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
5480 Decimal('0.00')
5481 >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
5482 Decimal('-0.77')
5483 >>> ExtendedContext.subtract(8, 5)
5484 Decimal('3')
5485 >>> ExtendedContext.subtract(Decimal(8), 5)
5486 Decimal('3')
5487 >>> ExtendedContext.subtract(8, Decimal(5))
5488 Decimal('3')
5489 """
5490 a = _convert_other(a, raiseit=True)
5491 r = a.__sub__(b, context=self)
5492 if r is NotImplemented:
5493 raise TypeError("Unable to convert %s to Decimal" % b)
5494 else:
5495 return r
5496
5497 def to_eng_string(self, a):
5498 """Convert to a string, using engineering notation if an exponent is needed.

Callers 2

test_subtractMethod · 0.95
check_ulpdiffMethod · 0.45

Calls 2

_convert_otherFunction · 0.85
__sub__Method · 0.45

Tested by 1

test_subtractMethod · 0.76