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


Groups > comp.lang.python > #73662

Re: python 3.44 float addition bug?

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!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.158
X-Spam-Level *
X-Spam-Evidence '*H*': 0.71; '*S*': 0.03; 'binary': 0.07; 'subject:bug': 0.07; 'subject:python': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; '2.0': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'range': 0.61; "you're": 0.61; 'more': 0.64; '26,': 0.68; '"high"': 0.84; 'inherent': 0.84; 'average': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=K/x8zCxQ2k8Fak1qpqD/terJUa/NAvRQZ5SVRWk2So8=; b=tzlxp0AP1OtvDvYFLUFLCK4spknzEK83uuSeYqNwYIczZDQ/gR1UyZN4OaTdYvkMTy 019UbfmkxN2dN2ijD8QCJcXDbGZ4TpUSQTahF3MNsrkotLW3I4r38IvlbPgaAUvbmg2m 6YKDCUIBlgnDxRWaNcT28ZEKiBUtw0xBoXtw0s78/F1IUYTA9++rVKdLyrKvsJn7zLSO YsPfFWHWDOfnSizXj15+vdd52sRqrSEw5rvOhAoZgr0hUvt1pl+Qv7R5xUv+/ruvs7MH iPfsN7JIWOdNEOrc0NeAkBSbSRrkQRR74244RB64frVXihg5VpDurhEOPb5koOh0tOn6 LksQ==
X-Received by 10.69.31.107 with SMTP id kl11mr32218656pbd.70.1403885975306; Fri, 27 Jun 2014 09:19:35 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAPTjJmqPMb1EU6FceuW6+PGTBRmE11m8Do4gACwxMyQvjFUJOg@mail.gmail.com>
References <XnsA35313E634BA0fraserlonggmailcom34@216.196.109.145> <645be4a7-2e1b-44a4-9c45-9184c6df5518@googlegroups.com> <53ab8bc4$0$11121$c3e8da3@news.astraweb.com> <mailman.11251.1403753977.18130.python-list@python.org> <53abe4ad$0$11121$c3e8da3@news.astraweb.com> <mailman.11254.1403775938.18130.python-list@python.org> <53acdc2d$0$29985$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqPMb1EU6FceuW6+PGTBRmE11m8Do4gACwxMyQvjFUJOg@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 27 Jun 2014 10:18:54 -0600
Subject Re: python 3.44 float addition bug?
To Python <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.11289.1403885983.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403885983 news.xs4all.nl 2974 [2001:888:2000:d::a6]:46393
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73662

Show key headers only | View raw


On Thu, Jun 26, 2014 at 9:24 PM, Chris Angelico <rosuav@gmail.com> wrote:
> But you're right that this can be very surprising. And it's inherent
> to the concept of digits having more range than just "high" or "low",
> so there's no way you can get this with binary floats.

For an average of two numbers, I think that's true.  For an average of
more than two numbers, it's possible.

>>> a = 2.0 ** 53 - 1
>>> b = 2.0 ** 53 - 2
>>> a
9007199254740991.0
>>> b
9007199254740990.0
>>> (a + b + b) / 3
9007199254740989.0

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


Thread

python 3.44 float addition bug? FraserL <fraser.long+usenet@NOSPAMgmail.com> - 2014-06-20 19:57 -0500
  Re: python 3.44 float addition bug? FraserL <fraser.long+usenet@gmail.com> - 2014-06-20 20:11 -0500
    Re: python 3.44 float addition bug? Gary Herron <gary.herron@islandtraining.com> - 2014-06-20 18:19 -0700
  Re: python 3.44 float addition bug? Gary Herron <gary.herron@islandtraining.com> - 2014-06-20 18:07 -0700
  Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-21 11:33 +1000
  Re: python 3.44 float addition bug? INADA Naoki <songofacandy@gmail.com> - 2014-06-21 10:06 +0900
  Re: python 3.44 float addition bug? Grant Edwards <invalid@invalid.invalid> - 2014-06-21 14:25 +0000
  Re: python 3.44 float addition bug? Ned Deily <nad@acm.org> - 2014-06-21 12:24 -0700
    Re: python 3.44 float addition bug? buck <workitharder@gmail.com> - 2014-06-23 17:55 -0700
      Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-24 13:26 +1000
      Re: python 3.44 float addition bug? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-06-24 17:30 +1200
      Re: python 3.44 float addition bug? Steven D'Aprano <steve@pearwood.info> - 2014-06-24 06:34 +0000
  Re: python 3.44 float addition bug? Maciej Dziardziel <fiedzia@gmail.com> - 2014-06-25 14:12 -0700
    Re: python 3.44 float addition bug? Steven D'Aprano <steve@pearwood.info> - 2014-06-26 02:56 +0000
      Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-26 13:13 +1000
        Re: python 3.44 float addition bug? Steven D'Aprano <steve@pearwood.info> - 2014-06-26 04:17 +0000
          Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-26 14:41 +1000
      Re: python 3.44 float addition bug? Ben Finney <ben@benfinney.id.au> - 2014-06-26 13:39 +1000
        Re: python 3.44 float addition bug? Steven D'Aprano <steve@pearwood.info> - 2014-06-26 09:15 +0000
          Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-26 19:38 +1000
            Re: python 3.44 float addition bug? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-27 02:51 +0000
              Re: python 3.44 float addition bug? Chris Angelico <rosuav@gmail.com> - 2014-06-27 13:24 +1000
              Re: python 3.44 float addition bug? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-27 10:18 -0600
      Re: python 3.44 float addition bug? Stefan Behnel <stefan_ml@behnel.de> - 2014-06-26 07:53 +0200

csiph-web