Python math is off by .000000000000045
Ian Kelly
ian.g.kelly at gmail.com
Wed Feb 22 19:26:12 CET 2012
On Wed, Feb 22, 2012 at 11:13 AM, Alec Taylor <alec.taylor6 at gmail.com> wrote:
> Simple mathematical problem, + and - only:
>
>>>> 1800.00-1041.00-555.74+530.74-794.95
> -60.950000000000045
>
> That's wrong.
>
> Proof
> http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95
> -60.95 aka (-(1219/20))
>
> Is there a reason Python math is only approximated? - Or is this a bug?
http://docs.python.org/faq/design.html#why-are-floating-point-calculations-so-inaccurate
More information about the Python-list
mailing list