converting float to int issue
Gilles Lenfant
glenfant at NOSPAM.bigfoot.com
Mon May 5 14:43:54 EDT 2003
"Alex" <delete.this.part.alex.news at attbi.com> a écrit dans le message de
news: PXxta.502509$Zo.109454 at sccrnsc03...
> Converting a float to an int produces strange results. Is this just a bug
> or am I missing something? I tried to search the bug database, but was
> unsucsessful.
>
> Converting a float to a long works as I would expect.
>
> Python 2.2.2 (#1, Apr 16 2003, 22:00:16)
> [GCC 3.2.1 20021207 (Gentoo Linux 3.2.1-20021207)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> int(1.0)
> 0
> >>> int(3.0)
> 0
> >>> int(3.14)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> OverflowError: float too large to convert
Strange !!
PythonWin 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32.
>>> int(3.14)
3
>>>
Same thing in Python 2.1.3/FreeBSD
--Gilles
More information about the Python-list
mailing list