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

Method __int__

Lib/_pydecimal.py:1574–1585  ·  view source on GitHub ↗

Converts self to an int, truncating if necessary.

(self)

Source from the content-addressed store, hash-verified

1572 return float(s)
1573
1574 def __int__(self):
1575 """Converts self to an int, truncating if necessary."""
1576 if self._is_special:
1577 if self._isnan():
1578 raise ValueError("Cannot convert NaN to integer")
1579 elif self._isinfinity():
1580 raise OverflowError("Cannot convert infinity to integer")
1581 s = (-1)**self._sign
1582 if self._exp >= 0:
1583 return s*int(self._int)*10**self._exp
1584 else:
1585 return s*int(self._int[:self._exp] or '0')
1586
1587 __trunc__ = __int__
1588

Callers

nothing calls this directly

Calls 2

_isnanMethod · 0.95
_isinfinityMethod · 0.95

Tested by

no test coverage detected