Normalize- strip trailing 0s, change anything equal to 0 to 0e0
(self, context=None)
| 2519 | return other.__pow__(self, context=context) |
| 2520 | |
| 2521 | def normalize(self, context=None): |
| 2522 | """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" |
| 2523 | |
| 2524 | if context is None: |
| 2525 | context = getcontext() |
| 2526 | |
| 2527 | if self._is_special: |
| 2528 | ans = self._check_nans(context=context) |
| 2529 | if ans: |
| 2530 | return ans |
| 2531 | |
| 2532 | dup = self._fix(context) |
| 2533 | if dup._isinfinity(): |
| 2534 | return dup |
| 2535 | |
| 2536 | if not dup: |
| 2537 | return _dec_from_triple(dup._sign, '0', 0) |
| 2538 | exp_max = [context.Emax, context.Etop()][context.clamp] |
| 2539 | end = len(dup._int) |
| 2540 | exp = dup._exp |
| 2541 | while dup._int[end-1] == '0' and exp < exp_max: |
| 2542 | exp += 1 |
| 2543 | end -= 1 |
| 2544 | return _dec_from_triple(dup._sign, dup._int[:end], exp) |
| 2545 | |
| 2546 | def quantize(self, exp, rounding=None, context=None): |
| 2547 | """Quantize self so its exponent is the same as that of exp. |
no test coverage detected