round() function strange behaviour

a.clarke11 a.clarke11 at pop.ntlworld.com
Sat Mar 9 18:46:49 EST 2002


Hi,

I think it's a bug intrinsic to the round function: I use a Mac, and I
tried differnt arguments for round. Where the decimal ends in nine, in
whatever decimal place I tried, the answer is a recurrent decimal,
usually nine but sometimes zero.
Has it been reported??

Tony

You wrote:

the round() function will sometimes return a predictable result, as
in:

round(45.67891, 2)
>>> 45.68

but sometimes it will return something like:

round(56.78923, 2)
>>> 56.789999999999999

2.1 and 2.2 both behave this way on two different (Windows) computers.
What's going on here?

Bruce Robbins




More information about the Python-list mailing list