converting float to int issue

Batista, Facundo FBatista at uniFON.com.ar
Mon May 5 14:21:32 EDT 2003


Works allright for me:

Python 2.1.1 (#1, Jan  6 2003, 16:05:24)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> int(3.0)
3
>>> int(3.14)
3
>>>

        Facundo


#- -----Mensaje original-----
#- De: Alex [mailto:delete.this.part.alex.news at attbi.com]
#- Enviado el: Lunes 5 de Mayo de 2003 3:21 PM
#- Para: python-list at python.org
#- Asunto: converting float to int issue
#-
#-
#- 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
#- >>> long(1.0)
#- 1L
#- >>> long(3.14)
#- 3L
#- >>> int(long(3.14))
#- 3
#-
#- --
#- http://mail.python.org/mailman/listinfo/python-list
#- 





More information about the Python-list mailing list