Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20691
| From | Christian Heimes <lists@cheimes.de> |
|---|---|
| Subject | Re: Python math is off by .000000000000045 |
| Date | 2012-02-22 19:26 +0100 |
| References | <CAO+9iGcg5aTuv1y_GYEMJAPw8zhOmS=tDKTjVsaBe77Q5cd6TA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.51.1329935200.3037.python-list@python.org> (permalink) |
Am 22.02.2012 19:13, schrieb Alec Taylor: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. That's only the correct answer for unlimited precision, not for IEEE-754 semantics. http://en.wikipedia.org/wiki/IEEE_754 > 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? Python uses the platforms double precision float datatype. Floats are almost never exact. Christian
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Python math is off by .000000000000045 Christian Heimes <lists@cheimes.de> - 2012-02-22 19:26 +0100 Re: Python math is off by .000000000000045 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-22 22:21 +0000
csiph-web