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

Method __int__

Lib/_pydecimal.py:1571–1582  ·  view source on GitHub ↗

Converts self to an int, truncating if necessary.

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

_isnanMethod · 0.95
_isinfinityMethod · 0.95

Tested by

no test coverage detected