round() function strange behaviour

brobbins333 at shaw.ca brobbins333 at shaw.ca
Sat Mar 9 17:59:13 EST 2002


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