round(22.47,2) gives 22.469999999999999?
Duncan Booth
duncan at NOSPAMrcp.co.uk
Wed Aug 6 07:27:08 EDT 2003
Eric van Riet Paap <eric at vanrietpaap.com> wrote in
news:3f30e294$0$125$e4fe514c at dreader5.news.xs4all.nl:
> Hi,
>
> 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?
>
> P.S. I haven't tested python2.3, but python1.5.2 doesn't have this
> problem.
>
>
Please read the FAQ, particularly entry 4.98 Why are floating point
calculations so inaccurate?
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list