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)
| 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. |