Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '0.1': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; "(i'm": 0.16; '0.3': 0.16; 'notation': 0.16; 'all.': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'pfxlen:0': 0.19; 'result.': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'precise': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; '>': 0.26; '15,': 0.26; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; "skip:' 10": 0.31; 'closer': 0.31; 'fedora': 0.31; 'url:python': 0.33; 'not.': 0.33; 'received:google.com': 0.35; 'i.e.': 0.36; 'subject:Simple': 0.36; 'ubuntu': 0.36; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'url:mail': 0.40; 'first': 0.61; 'to:addr:gmail.com': 0.65; '20,': 0.68; 'london,': 0.72; 'snow': 0.91 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:to :cc:content-type; bh=rxE1pWxLIoeI9fG5sWe9ie2FZ4UG96njbh5/WR0DBsg=; b=P+aiXAutg0ST32pv0AB0cQlbSsOuJYSsW5plkEMzWcCdhPG+O87ef6d0yKPzbsxF6k 9lLSAQhbvr523aoAW9qgi0WihV4ceUP702LPNQe2QydH0ESXAft1q9jKK/NRCIGPw0bJ Oe8aZtZabsi+4YROqc55w7G70ptmKnqKuzX8PU4agzCOt+tQCS36Mr63HJcTHx6Gy2T2 sRgzdrDv7JCRoopspfvkgZZf74d7WH8OHXzjajp7I5Gdvbu/VBKArtIcTRvxJof147Ac O2lQTFXKEw3qcGD/cYdrYBBjSHkr1MGU3mFENVfpHbkXSZYenaOriPOkFcnrjKvEvb8B pC2g== MIME-Version: 1.0 X-Received: by 10.52.23.97 with SMTP id l1mr2035334vdf.11.1397586504992; Tue, 15 Apr 2014 11:28:24 -0700 (PDT) In-Reply-To: <534D7807.6050408@gmail.com> References: <534D7807.6050408@gmail.com> Date: Tue, 15 Apr 2014 14:28:24 -0400 Subject: Re: Simple question From: Joel Goldstick To: phildobbin@gmail.com Content-Type: multipart/alternative; boundary=20cf3079bc642c4ab004f718f78d Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397586513 news.xs4all.nl 2852 [2001:888:2000:d::a6]:34510 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70280 --20cf3079bc642c4ab004f718f78d Content-Type: text/plain; charset=UTF-8 On Apr 15, 2014 2:19 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.....' > It's not. Look at the end of the result. It's scientific notation for a very small number > 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? > > Many thanks, > > 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 > > -- > https://mail.python.org/mailman/listinfo/python-list --20cf3079bc642c4ab004f718f78d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Apr 15, 2014 2:19 PM, "Phil Dobbin" <phildobbin@gmail.com> 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.....'
>
It's not. Look at the end of the result. It's scientific notation f= or a very small number
> 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?
>
> Many thanks,
>
> Cheers,
>
> =C2=A0 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://ph= ildobbin.org/publickey.asc
> Based in London, UK
>
> --
> https= ://mail.python.org/mailman/listinfo/python-list

--20cf3079bc642c4ab004f718f78d--