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

Method __int__

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

Converts self to an int, truncating if necessary.

(self)

Source from the content-addressed store, hash-verified

1628 return float(s)
1629
1630 def __int__(self):
1631 """Converts self to an int, truncating if necessary."""
1632 if self._is_special:
1633 if self._isnan():
1634 raise ValueError("Cannot convert NaN to integer")
1635 elif self._isinfinity():
1636 raise OverflowError("Cannot convert infinity to integer")
1637 s = (-1)**self._sign
1638 if self._exp >= 0:
1639 return s*int(self._int)*10**self._exp
1640 else:
1641 return s*int(self._int[:self._exp] or '0')
1642
1643 __trunc__ = __int__
1644

Callers

nothing calls this directly

Calls 2

_isnanMethod · 0.95
_isinfinityMethod · 0.95

Tested by

no test coverage detected