subtraction of floating point numbers

Chris Rebert clp2 at rebertia.com
Fri Feb 24 11:16:29 CET 2012


On Fri, Feb 24, 2012 at 12:41 AM, Jaroslav Dobrek
<jaroslav.dobrek at gmail.com> wrote:
> Hello,
>
> when I have Python subtract floating point numbers it yields weird
> results. Example:
>
> 4822.40 - 4785.52 = 36.8799999999992
>
> Why doesn't Python simply yield the correct result? It doesn't have a
> problem with this:
>
> 482240 - 478552 = 3688
>
> Can I tell Python in some way to do this differently?

Refer to this thread from 2 days ago:
http://mail.python.org/pipermail/python-list/2012-February/1288344.html

Regards,
Chris



More information about the Python-list mailing list