[New-bugs-announce] [issue11144] int(float) may return a long for no reason

Armin Rigo report at bugs.python.org
Mon Feb 7 18:45:55 CET 2011

New submission from Armin Rigo <arigo at users.sourceforge.net>:

On 32 bits, there is no reason to get a 'long' here:

>>> int(float(sys.maxint))
>>> int(int(float(sys.maxint)))
>>> int(float(-sys.maxint-1))
>>> int(int(float(-sys.maxint-1)))

On 64 bits, it's another story because floats cannot store 64 bits of precision.  However, -sys.maxint-1 can still be represented exactly in a float, and the same issue occurs:

>>> int(float(-sys.maxint-1))
>>> int(int(float(-sys.maxint-1)))

components: Interpreter Core
messages: 128143
nosy: arigo
priority: normal
severity: normal
status: open
title: int(float) may return a long for no reason
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list