round(22.47,2) gives 22.469999999999999?

John Machin sjmachin at lexicon.net
Thu Aug 7 00:29:44 CEST 2003


Daniel Klein <danielk at aracnet.com> wrote in message news:<u6u1jvo9cj3a1s853q4lm06h8358ho8ab0 at 4ax.com>...
> On Wed, 06 Aug 2003 13:12:21 +0200, Eric van Riet Paap
> <eric at vanrietpaap.com> 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?
> 
> Wouldn't
> 
> int(22.47 + .5)
> 
> get you to where you want to go?

Sure would, if 22 was where you wanted to go. One trusts that you
would be lonely on arrival, though. Perhaps you might then notice a
bunch of folks over at 22.47 ...




More information about the Python-list mailing list