Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.187 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.63; '*S*': 0.00; '0.1': 0.09; 'subject:question': 0.10; 'python': 0.11; '"..."': 0.16; "(i'm": 0.16; '0.3': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'later': 0.20; 'header:User-Agent:1': 0.23; 'precise': 0.24; 'cheers,': 0.24; "i've": 0.25; '15,': 0.26; 'first,': 0.26; 'this:': 0.26; 'header :In-Reply-To:1': 0.27; 'wondering': 0.29; "doesn't": 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'closer': 0.31; 'fedora': 0.31; 'helpful.': 0.31; 'quite': 0.32; 'url:python': 0.33; 'link.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'i.e.': 0.36; 'subject:Simple': 0.36; 'ubuntu': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'hope': 0.61; 'introduced': 0.61; 'url:3': 0.61; 'first': 0.61; 'more': 0.64; 'close': 0.67; 'header:Reply-To:1': 0.67; '20,': 0.68; 'reply- to:no real name:2**0': 0.71; 'london,': 0.72; 'saw': 0.77; 'reply- to:addr:gmail.com': 0.80; 'phil': 0.84; '1:18': 0.91; 'snow': 0.91; 'ware': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:organization:user-agent:mime-version :to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=QCPZP5qKkll2VRW+p8mvRdAi0nqenovU+rBlWzrMfso=; b=UE3OrWBveprTswBz7F7gt3Pxe1U2TXAyfLBX056kEl3Gt/hYOrr76y7UiNgYerj2A7 g2KwX+L5QHofAvUQmuaGUhGm3i9bmJo7uarrTTwkg+kBO0QhFfkaxNZnlrMqjERazxIa d6AdYfmG7nubPpZgJjBoDmJ754JsKYfw059Ny+3TMBfnXNXu4oA/NZI85iWNAW7/tGUM 7nTfWqkKYJl3PtOOgfLZxNlPFeCk4cQCqvuz668YNC+8sMhDCLFVOsKKpSfInaESm/hs F5mMjLzJkdVdz+31Dtuf7ztimgpXwtNhr7EzMGeX3MQ62ZaGY3VD+SY2En/05ZF1oDRi lj8Q== X-Received: by 10.194.9.73 with SMTP id x9mr58030wja.79.1397586698263; Tue, 15 Apr 2014 11:31:38 -0700 (PDT) Date: Tue, 15 Apr 2014 19:31:36 +0100 From: Phil Dobbin Organization: Horse Latitudes Ltd User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Simple question References: <534D7807.6050408@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: phildobbin@gmail.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397586705 news.xs4all.nl 2867 [2001:888:2000:d::a6]:40834 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70282 On 15/04/2014 19:25, Zachary Ware wrote: > On Tue, Apr 15, 2014 at 1:18 PM, Phil Dobbin wrote: >> Hi, all. >> >> I've just started to learn Python (I'm reading Mark Lutz's 'Learning >> Python' from O'Reilly) & I'm confused as to this part: >> >> '>>> 0.1 + 0.1 + 0.1 - 0.3 >> 5.55111.....' >> >> Using 'import Decimal' you can get a much closer result i.e. >> 'Decimal('0.0')' >> >> What I'm wondering is why the first calculation that arrives at >> '5.55111...' is so far out? > > First, note that the "..." part of "5.55111..." is very important > here, it's actually "5.55111...e-17" which means it's really > approximately 0.000000000000000055111, which is really very close to > the answer you'd expect from a human. To learn more about why Python > doesn't give 0.0, read this: > https://docs.python.org/3/tutorial/floatingpoint.html > > Hope this helps, > Hi, Zach. I saw the 'e-17' appended to the end but was unsure of its meaning ( quite a number of things are introduced in the book with clarification of their meaning not forthcoming 'til later on). Thank you for the link. It'll be very helpful. Cheers, Phil... -- currently (ab)using CentOS 6.5, Debian Squeeze & Wheezy, Fedora 19 & 20, OS X Snow Leopard, RHEL 7, Ubuntu Precise & Saucy GnuGPG Key : http://phildobbin.org/publickey.asc Based in London, UK