MCPcopy Index your code
hub / github.com/python/cpython / _fix_nan

Method _fix_nan

Lib/_pydecimal.py:1603–1613  ·  view source on GitHub ↗

Decapitate the payload of a NaN to fit the context

(self, context)

Source from the content-addressed store, hash-verified

1601 return complex(float(self))
1602
1603 def _fix_nan(self, context):
1604 """Decapitate the payload of a NaN to fit the context"""
1605 payload = self._int
1606
1607 # maximum length of payload is precision if clamp=0,
1608 # precision-1 if clamp=1.
1609 max_payload_len = context.prec - context.clamp
1610 if len(payload) > max_payload_len:
1611 payload = payload[len(payload)-max_payload_len:].lstrip('0')
1612 return _dec_from_triple(self._sign, payload, self._exp, True)
1613 return Decimal(self)
1614
1615 def _fix(self, context):
1616 """Round if it is necessary to keep self within prec precision.

Callers 4

_check_nansMethod · 0.95
_fixMethod · 0.95
_power_moduloMethod · 0.95
handleMethod · 0.80

Calls 3

_dec_from_tripleFunction · 0.85
DecimalClass · 0.85
lstripMethod · 0.45

Tested by

no test coverage detected