MCPcopy Index your code
hub / github.com/RustPython/RustPython / _fix_nan

Method _fix_nan

Lib/_pydecimal.py:1600–1610  ·  view source on GitHub ↗

Decapitate the payload of a NaN to fit the context

(self, context)

Source from the content-addressed store, hash-verified

1598 return complex(float(self))
1599
1600 def _fix_nan(self, context):
1601 """Decapitate the payload of a NaN to fit the context"""
1602 payload = self._int
1603
1604 # maximum length of payload is precision if clamp=0,
1605 # precision-1 if clamp=1.
1606 max_payload_len = context.prec - context.clamp
1607 if len(payload) > max_payload_len:
1608 payload = payload[len(payload)-max_payload_len:].lstrip('0')
1609 return _dec_from_triple(self._sign, payload, self._exp, True)
1610 return Decimal(self)
1611
1612 def _fix(self, context):
1613 """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 4

lenFunction · 0.85
_dec_from_tripleFunction · 0.85
DecimalClass · 0.85
lstripMethod · 0.45

Tested by

no test coverage detected