Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20690

Re: Python math is off by .000000000000045

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Python math is off by .000000000000045
Date 2012-02-22 18:24 +0000
References <CAO+9iGcg5aTuv1y_GYEMJAPw8zhOmS=tDKTjVsaBe77Q5cd6TA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.50.1329935101.3037.python-list@python.org> (permalink)

Show all headers | View raw


On 22/02/2012 18:13, Alec Taylor 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?
>
> Thanks for all info,
>
> Alec Taylor

Please google for floating point numbers.

-- 
Cheers.

Mark Lawrence.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python math is off by .000000000000045 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-22 18:24 +0000

csiph-web