converting float to int issue
Grant Edwards
grante at visi.com
Mon May 5 14:30:53 EDT 2003
In article <PXxta.502509$Zo.109454 at sccrnsc03>, Alex wrote:
> 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
Too weird.
Works fine here:
$ python2
Python 2.2.2 (#1, Jan 30 2003, 21:26:22)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> int(1.0)
1
>>> int(3.0)
3
>>> int(3.14)
3
>>>
I notice python was built with different versions of gcc...
--
Grant Edwards grante Yow! Thousands of days of
at civilians... have produced
visi.com a... feeling for the
aesthetic modules --
More information about the Python-list
mailing list