Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12887
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'infinite': 0.07; 'python': 0.08; '>>>>': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'rounding': 0.09; 'subject:python': 0.11; 'am,': 0.12; 'binary': 0.13; 'float': 0.13; 'stored': 0.13; 'wrote:': 0.16; 'exists': 0.18; 'slightly': 0.19; 'result.': 0.21; 'header:In-Reply-To:1': 0.22; 'expect': 0.25; 'problem': 0.28; 'second': 0.29; 'print': 0.29; 'least': 0.31; 'error': 0.32; 'version': 0.32; 'does': 0.32; 'to:addr:python-list': 0.33; 'that,': 0.33; 'header:User-Agent:1': 0.34; 'header:X-Complaints-To:1': 0.35; '(for': 0.35; 'bigger': 0.37; 'subject:skip:m 10': 0.37; 'using': 0.37; 'but': 0.37; 'two': 0.37; 'received:org': 0.38; 'steven': 0.38; 'non': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'format.': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'double': 0.61; 'our': 0.63; 'skip:1 10': 0.63; 'skip:1 20': 0.82; '06:51': 0.84; 'estimated': 0.91; 'conclude': 0.95 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Gelonida N <gelonida@gmail.com> |
| Subject | Re: Floating point multiplication in python |
| Date | Wed, 07 Sep 2011 10:57:53 +0200 |
| References | <mailman.790.1315289581.27778.python-list@python.org> <j44rre$e4c$1@r03.glglgl.eu> <2204592.egLE2XKegd@PointedEars.de> <4e66f843$0$29969$c3e8da3$5496439d@news.astraweb.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | unicorn.dungeon.de |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 "" |
| In-Reply-To | <4e66f843$0$29969$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.827.1315385890.27778.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1315385890 news.xs4all.nl 2417 [2001:888:2000:d::a6]:36499 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12887 |
Show key headers only | View raw
On 09/07/2011 06:51 AM, Steven D'Aprano wrote: 11258999068426240 > > Error in float 1.1*1.1: > >>>> b = F(11, 10)**2 >>>> y = F.from_float(1.1**2) >>>> f = y - b >>>> print f > 21/112589990684262400 > > which is slightly more than double e above, and slightly less than our > estimate of 2*a*e = 11/56294995342131200 > > So we can conclude that, at least for 1.1**2, Python floats are more > accurate than we would expect from a simple application of the binomial > theorem. (For implementations using IEEE doubles.) The reason why the error is different from the 2*a*e is, that we encounter two problems. first problem is, that x = a + e e exists because a float does have a limited number (let's call it N) of digits and a has an infinite amount of non zero digits in the binary format. second problem is, that the result of the multiplication is not (a+e) * (a+e) but a 'rounded' version of it, because the floating point representation of the result would require about 2*N digits, whereas only N digits will be stored in the result. depending on the rounding which happened (up or down) the error will be bigger or smaller than the estimated one.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Floating point multiplication in python xyz <xyzhtml@163.com> - 2011-09-06 13:57 +0800
Re: Floating point multiplication in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 17:11 +1000
Re: Floating point multiplication in python Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-09-06 12:14 +0200
Re: Floating point multiplication in python Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-09-06 18:07 +0200
Re: Floating point multiplication in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-07 14:51 +1000
Re: Floating point multiplication in python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-06 23:35 -0700
Re: Floating point multiplication in python Gelonida N <gelonida@gmail.com> - 2011-09-07 10:57 +0200
Re: Floating point multiplication in python Terry Reedy <tjreedy@udel.edu> - 2011-09-07 05:37 -0400
csiph-web