Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20691 > unrolled thread
| Started by | Christian Heimes <lists@cheimes.de> |
|---|---|
| First post | 2012-02-22 19:26 +0100 |
| Last post | 2012-02-22 22:21 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Christian Heimes <lists@cheimes.de> |
|---|---|
| Date | 2012-02-22 19:26 +0100 |
| Subject | Re: Python math is off by .000000000000045 |
| Message-ID | <mailman.51.1329935200.3037.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-02-22 22:21 +0000 |
| Message-ID | <4f456a6b$0$29986$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #20691 |
On Wed, 22 Feb 2012 19:26:26 +0100, Christian Heimes wrote: > Python uses the platforms double precision float datatype. Floats are > almost never exact. Well, that's not quite true. Python floats are always exact. They just may not be exactly what you want :) Pedantic-but-unhelpful-as-always-ly y'rs, -- Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web