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