Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93436

Re: Bug in floating point multiplication

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 <rosuav@gmail.com>
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 <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.20+
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.253.1435851297.3674.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Fri, Jul 3, 2015 at 1:26 AM, Paul Rubin <no.email@nospam.invalid> wrote:
> Steven D'Aprano <steve@pearwood.info> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Bug in floating point multiplication Steven D'Aprano <steve@pearwood.info> - 2015-07-03 00:52 +1000
  Re: Bug in floating point multiplication Michael Poeltl <michael.poeltl@univie.ac.at> - 2015-07-02 17:10 +0200
  Re: Bug in floating point multiplication Chris Angelico <rosuav@gmail.com> - 2015-07-03 01:21 +1000
  Re: Bug in floating point multiplication Robin Becker <robin@reportlab.com> - 2015-07-02 16:24 +0100
  Re: Bug in floating point multiplication Paul Rubin <no.email@nospam.invalid> - 2015-07-02 08:26 -0700
    Re: Bug in floating point multiplication Chris Angelico <rosuav@gmail.com> - 2015-07-03 01:34 +1000
      Re: Bug in floating point multiplication Steven D'Aprano <steve@pearwood.info> - 2015-07-03 01:41 +1000
    Re: Bug in floating point multiplication Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-02 09:38 -0600
  Re: Bug in floating point multiplication Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2015-07-02 17:15 +0200
  Re: Bug in floating point multiplication Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-02 09:28 -0600
  Re: Bug in floating point multiplication Robin Becker <robin@reportlab.com> - 2015-07-02 16:29 +0100
  Re: Bug in floating point multiplication Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-02 09:32 -0600
  Re: Bug in floating point multiplication Steven D'Aprano <steve@pearwood.info> - 2015-07-03 01:42 +1000
  Re: Bug in floating point multiplication duncan smith <buzzard@invalid.invalid> - 2015-07-02 17:08 +0100
  Re: Bug in floating point multiplication MRAB <python@mrabarnett.plus.com> - 2015-07-02 17:20 +0100
  Re: Bug in floating point multiplication Tim Chase <python.list@tim.thechases.com> - 2015-07-02 11:59 -0500
  Re: Bug in floating point multiplication Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-07-02 19:49 +0200
    Re: Bug in floating point multiplication Ned Deily <nad@acm.org> - 2015-07-02 22:07 -0700
      Re: Bug in floating point multiplication Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-07-03 18:27 +0200
  Re: Bug in floating point multiplication Laurent Pointal <laurent.pointal@free.fr> - 2015-07-02 23:12 +0200
  Re: Bug in floating point multiplication Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-07-03 16:13 +0100
  Re: Bug in floating point multiplication Laura Creighton <lac@openend.se> - 2015-07-05 00:54 +0200
  Re: Bug in floating point multiplication Peter Otten <__peter__@web.de> - 2015-07-05 09:38 +0200

csiph-web