[Python-bugs-list] int() broken? (PR#370)

wzdd@sesgroup.net wzdd@sesgroup.net
Mon, 26 Jun 2000 03:34:58 -0400 (EDT)


Full_Name: Nicholas FitzRoy-Dale
Version: 1.5.2
OS: Linux (Debian, Red Hat)
Submission from: cpe-24-192-0-130.vic.bigpond.net.au (24.192.0.130)


The following typescript illustrates the problem. I understand int() truncates
towards zero - but can't see why it would round down by a whole int value!

The same behaviour is apparent on a Red Hat 6.2 system, where Python was built
with egcs.

~$ python
Python 1.5.2 (#0, Apr  3 2000, 14:46:48)  [GCC 2.95.2 20000313 (Debian
GNU/Linux)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> test=591.92
>>> test*100
59192.0
>>> int (test*100)
59191
>>> 

... and yet:
>>> int (test*100+0.1)
59192
>>>