normalize reduces an operand to its simplest form. Essentially a plus operation with all trailing zeros removed from the result. >>> ExtendedContext.normalize(Decimal('2.1')) Decimal('2.1') >>> ExtendedContext.normalize(Decimal('-2.0')) Decimal('-2')
(self, a)
| 5026 | return a.next_toward(b, context=self) |
| 5027 | |
| 5028 | def normalize(self, a): |
| 5029 | """normalize reduces an operand to its simplest form. |
| 5030 | |
| 5031 | Essentially a plus operation with all trailing zeros removed from the |
| 5032 | result. |
| 5033 | |
| 5034 | >>> ExtendedContext.normalize(Decimal('2.1')) |
| 5035 | Decimal('2.1') |
| 5036 | >>> ExtendedContext.normalize(Decimal('-2.0')) |
| 5037 | Decimal('-2') |
| 5038 | >>> ExtendedContext.normalize(Decimal('1.200')) |
| 5039 | Decimal('1.2') |
| 5040 | >>> ExtendedContext.normalize(Decimal('-120')) |
| 5041 | Decimal('-1.2E+2') |
| 5042 | >>> ExtendedContext.normalize(Decimal('120.00')) |
| 5043 | Decimal('1.2E+2') |
| 5044 | >>> ExtendedContext.normalize(Decimal('0.00')) |
| 5045 | Decimal('0') |
| 5046 | >>> ExtendedContext.normalize(6) |
| 5047 | Decimal('6') |
| 5048 | """ |
| 5049 | a = _convert_other(a, raiseit=True) |
| 5050 | return a.normalize(context=self) |
| 5051 | |
| 5052 | def number_class(self, a): |
| 5053 | """Returns an indication of the class of the operand. |