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