Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '__future__': 0.09; 'subject:skip:m 10': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'assume': 0.11; 'anyway': 0.11; 'discussions': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'threw': 0.16; 'wrote:': 0.16; 'copied': 0.18; 'integer': 0.18; 'runs': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; '2.x': 0.22; 'am,': 0.23; '2015': 0.23; 'normally': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'message- id:@mail.gmail.com': 0.28; 'fedora': 0.29; 'fri,': 0.31; 'error.': 0.31; 'code': 0.31; "can't": 0.32; 'possibly': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'previous': 0.34; 'received:google.com': 0.34; 'but': 0.36; '(and': 0.36; 'subject:: ': 0.37; 'means': 0.39; 'forget': 0.60; 'your': 0.60; 'future': 0.61; 'default': 0.61; 'here.': 0.61; 'jul': 0.72; 'chrisa': 0.84; 'to:none': 0.90 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=QgMt/qzVbKtWN4TCw8YBnKz+5F8NyQRp9QJb02OXcrA=; b=tn9xMd21QWzHzXsY/Gi6Pg/+TXxUFBHgjBq/l9D6E+//ynqWQ8Z9VWEoV3Y1zRc0+b UHQKAYtr8elMZJuvwfwQzWhi4pJMr8Ev+QZdIz7hKNmKp1Do2WVmXNGSRBqo7pnPmYcp eknY2eCFPuNGORnHg/iie+lxZdvPOzYRtFSLoe5zH6F3EpByNWNU4oFOdBjCnBQUO+YM Eu/DdeliW3XpQy2VpDpXQqgk/kjI5GCUbe6ElIarkLniftgIiESakQPZRJLf9OLgkZ/e aTbzUPkPxLm7KTNWiFcDAtQnFb/oPK9opTa3ZZqlXLfF9Uht/4UZ9xHMx7MwAcbIY0qX aj3g== MIME-Version: 1.0 X-Received: by 10.50.43.196 with SMTP id y4mr15330885igl.14.1435851295569; Thu, 02 Jul 2015 08:34:55 -0700 (PDT) In-Reply-To: <87a8vepomp.fsf@nightsong.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <87a8vepomp.fsf@nightsong.com> Date: Fri, 3 Jul 2015 01:34:55 +1000 Subject: Re: Bug in floating point multiplication From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435851297 news.xs4all.nl 2940 [2001:888:2000:d::a6]:34647 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3900 X-Received-Body-CRC: 2042910125 Xref: csiph.com comp.lang.python:93436 On Fri, Jul 3, 2015 at 1:26 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> x = 1 - 1/2**53 >> assert x == 0.9999999999999999 > > In Python 2.x I don't see how that assert can possibly succeed, since > x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 > and it threw an assertion error. >From previous discussions I happen to know that Steven normally runs everything with "from __future__ import division" active (and possibly others? not sure), so just assume he means to work with floats here. Steven, I think this is one of the downsides of using future directives by default - you forget that your code can't always be copied and pasted to other people :) ChrisA