MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / normalize

Method normalize

tools/python-3.11.9-amd64/Lib/_pydecimal.py:2521–2544  ·  view source on GitHub ↗

Normalize- strip trailing 0s, change anything equal to 0 to 0e0

(self, context=None)

Source from the content-addressed store, hash-verified

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.

Callers 5

_expand_langFunction · 0.45
map_table_b2Function · 0.45
normalizeMethod · 0.45
optimizeFunction · 0.45
checkFunction · 0.45

Calls 6

_check_nansMethod · 0.95
_fixMethod · 0.95
getcontextFunction · 0.85
_dec_from_tripleFunction · 0.85
_isinfinityMethod · 0.80
EtopMethod · 0.80

Tested by

no test coverage detected