Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70279
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; '16,': 0.03; 'output': 0.05; '0.1': 0.09; 'explanation': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '0.3': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'zero.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'wondering': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'decimal': 0.31; 'actual': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'subject:Simple': 0.36; 'does': 0.39; 'full': 0.61; "you're": 0.61; 'first': 0.61; 'places': 0.64; 'close': 0.67; 'fact,': 0.69; 'phil': 0.84; 'to:none': 0.92; 'incredibly': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Ujzq7KHS2GqqE9+Z+XZ1vU/wd/JgCIjMWXW2dKKV6dM=; b=sojIXVJkhrZoVOCxsQdovURlNsjPVQAWDkdRRciI19CnY5y9U5lu5/hZReKjWDKAi2 cvG0ka/NzUmWpqtkBhO0UeZq+Q6gdioUpwsB9kls9kN32sVNie2tETtt39FIylK+QjrV /okZTZ2lQi1S89hU/NI7Z3SrLYlPeQZQF5bZjT+THVG7jJGyf8S0NS7heb9kMNPbdSYh HZj+mmwZY3EdTZ3hgyBSFVlKCjNh52xc62Lp8juOfAmVKS2oYJtVcde2LG+0PV50Lf08 texPF6r7+oijxpj2szszor6HqjQqUelHd6jOFjLMnSBdAsUxEeADtJ0KYqxd0HHkBh7R mOBg== |
| MIME-Version | 1.0 |
| X-Received | by 10.220.163.3 with SMTP id y3mr2441486vcx.7.1397586429847; Tue, 15 Apr 2014 11:27:09 -0700 (PDT) |
| In-Reply-To | <534D7807.6050408@gmail.com> |
| References | <534D7807.6050408@gmail.com> |
| Date | Wed, 16 Apr 2014 04:27:09 +1000 |
| Subject | Re: Simple question |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9285.1397586432.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1397586432 news.xs4all.nl 2939 [2001:888:2000:d::a6]:32942 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:70279 |
Show key headers only | View raw
On Wed, Apr 16, 2014 at 4:18 AM, Phil Dobbin <phildobbin@gmail.com> wrote: > '>>> 0.1 + 0.1 + 0.1 - 0.3 > 5.55111.....' > > What I'm wondering is why the first calculation that arrives at > '5.55111...' is so far out? There's something you're not seeing here. In full, the output I see is: >>> 0.1 + 0.1 + 0.1 - 0.3 5.551115123125783e-17 See that bit at the end? "e-17" means "times ten to the -17th power" - that is, move the decimal point 17 places to the left. So the actual value is: >>> "%50.50f"%(0.1 + 0.1 + 0.1 - 0.3) '0.00000000000000005551115123125782702118158340454102' It's not actually as far out as you think; in fact, that's incredibly close to zero. A full explanation of why floating point arithmetic does this can be found in many places on the internet, but the main thing to note is that it really isn't showing 5.5. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Simple question Chris Angelico <rosuav@gmail.com> - 2014-04-16 04:27 +1000
csiph-web