MCPcopy Index your code
hub / github.com/RustPython/RustPython / subtract

Method subtract

Lib/_pydecimal.py:5471–5492  ·  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

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

Callers 1

test_subtractMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__sub__Method · 0.45

Tested by 1

test_subtractMethod · 0.76