round(22.47,2) gives 22.469999999999999?

Tim Roberts timr at
Fri Aug 8 06:06:18 CEST 2003

Daniel Klein <danielk at> wrote:

>Eric van Riet Paap <eric at> wrote:
>>On python2.1.3, python2.2.1 and python2.2.3 round(22.47,2) gives 
>>22.469999999999999 . Does anyone know if this is a bug or some weird, yet 
>>unexpected, behaviour?
>int(22.47 + .5)
>get you to where you want to go?

No, you didn't read the assignment.  :)

round(22.47,2) gives roughly 22.47.  int(22.47+.5) gives 22.  VERY
different numbers.
- Tim Roberts, timr at
  Providenza & Boekelheide, Inc.

More information about the Python-list mailing list