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


Groups > comp.lang.python > #93433

Re: Bug in floating point multiplication

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'happen.': 0.09; 'reports.': 0.09; 'subject:skip:m 10': 0.09; 'python': 0.11; '2.7': 0.13; 'thu,': 0.15; 'reproduce': 0.16; 'trusty': 0.16; 'wrote:': 0.16; 'runs': 0.18; 'do.': 0.22; '64-bit': 0.22; 'title,': 0.22; 'am,': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'url:bugs': 0.24; 'message-id:@mail.gmail.com': 0.28; 'appear': 0.29; 'builds.': 0.29; 'prints': 0.29; '(which': 0.29; 'correct': 0.29; 'url:mailman': 0.31; 'code': 0.31; "can't": 0.32; 'system,': 0.32; 'anyone': 0.32; 'probably': 0.32; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'ubuntu': 0.33; '(for': 0.34; 'received:google.com': 0.34; 'url:listinfo': 0.35; 'to:addr :python-list': 0.35; 'reply.': 0.35; 'url:org': 0.36; 'so,': 0.37; 'should': 0.37; 'operating': 0.37; 'subject:: ': 0.37; 'version': 0.38; 'to:addr:python.org': 0.39; 'system.': 0.39; 'your': 0.60; 'necessarily': 0.61; 'more': 0.62; 'results.': 0.63; 'reply': 0.67; 'jul': 0.72; 'to:name:python': 0.84
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=c63Bpa5hK+7+xE9JUhknclaQm77D4B5a+lFkoNXMuJg=; b=sD7DVeUz/o0yr7osCW/YXBKWzfOMgM0wwETcpot6OTmXzwrC9ojzUAuTKJ0Ib/pmkC fn90J7y6Tid+BKPoAqGnrdsY7UA724Y6RBmNEbgVWrzfJQHmIDXibYGKei+Z4a1EiqMW pkUKIOvTeTulGcxy1xQ0ETZtvq5Sqhoz/GpAsGFB81U8bdqTAnAsTP15LqGi5xB5FIKs KqL+iMkctQaLqXzcD76auVzHw37F/e8nvd1kZplWljwhnpq2yk+V2/Ax/iBR41Iiej+v kkKPoPzF3NInluhbR0Wx3z43/3xo+a7YLMRJB+2ubPkEJ36sG+2nWKr2+X63gb/QeePu mzRA==
X-Received by 10.170.197.205 with SMTP id o196mr38890849yke.93.1435850961847; Thu, 02 Jul 2015 08:29:21 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com>
References <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 2 Jul 2015 09:28:42 -0600
Subject Re: Bug in floating point multiplication
To Python <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.250.1435850964.3674.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1435850964 news.xs4all.nl 2930 [2001:888:2000:d::a6]:52408
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:93433

Show key headers only | View raw


On my Chromebook, using Python 2.7.6 from the Ubuntu Trusty
distribution, I get AssertionError, and x == 1.

In Python 3.4.0 on the same system, the code runs to completion. Both
Pythons appear to be 64-bit builds.

On my Mint 17.1 desktop (which should be using the same packages), I
get the same results.

On Thu, Jul 2, 2015 at 8:52 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> Despite the title, this is not one of the usual "Why can't Python do
> maths?" "bug" reports.
>
> Can anyone reproduce this behaviour? If so, please reply with the version of
> Python and your operating system. Printing sys.version will probably do.
>
>
> x = 1 - 1/2**53
> assert x == 0.9999999999999999
> for i in range(1, 1000000):
>     if int(i*x) == i:
>         print(i); break
>
>
> Using Jython and IronPython, the loop runs to completion. That is the
> correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and
> 3.3 on Centos and Debian, it prints 2049 and breaks. That should not
> happen. If you can reproduce that (for any value of i, not necessarily
> 2049), please reply.
>
> See also http://bugs.python.org/issue24546 for more details.
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list

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