Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'happen.': 0.09; 'reports.': 0.09; 'subject:skip:m 10': 0.09; 'cc:addr:python- list': 0.10; 'python': 0.11; '2.7': 0.13; ':-)': 0.14; 'reproduce': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wien,': 0.16; 'runs': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'do.': 0.22; 'title,': 0.22; 'cc:no real name:2**0': 0.23; 'header:In-Reply-To:1': 0.24; 'url:bugs': 0.24; 'header:User-Agent:1': 0.26; 'linux': 0.26; "i'm": 0.29; 'prints': 0.29; 'correct': 0.29; 'url:mailman': 0.31; "can't": 0.32; 'anyone': 0.32; 'probably': 0.32; 'url:python': 0.33; 'michael': 0.33; "d'aprano": 0.33; 'steven': 0.33; '(for': 0.34; 'running': 0.34; 'url:listinfo': 0.35; 'reply.': 0.35; 'url:org': 0.36; 'so,': 0.37; 'should': 0.37; 'operating': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'version': 0.38; 'system.': 0.39; 'content-disposition:inline': 0.60; 'your': 0.60; 'hope': 0.61; 'helps': 0.61; 'necessarily': 0.61; 'more': 0.62; 'physics': 0.66; 'materials': 0.67; 'reply': 0.67; 'received:at': 0.72; 'lernen': 0.84; 'true!': 0.84 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=univie.ac.at; s=rev2; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=1A5wIfasxYt0R/cHcCBekIMW5JLpoGt0lYkaI8Q48Og=; b=cf/+Ws//MFIEHPG78aDAhBa6AgtYCI7jEyMBBxvzCYZZJ2pcslZrBB1itZ11pMXmfmj3hG21uEo+tS+JmM+m3Oeyft/NZfCcRChOE4BkvlH+VwajzgQqjZr9CEp4qB4jFQEoObOtZGynwEWAB2bpL2un4IL9AizSSlpPxD2ULxo=; Date: Thu, 2 Jul 2015 17:10:50 +0200 From: Michael Poeltl To: Steven D'Aprano Cc: python-list@python.org Subject: Re: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Univie-Virus-Scan: scanned by ClamAV on justin.univie.ac.at 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435850461 news.xs4all.nl 2868 [2001:888:2000:d::a6]:40123 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93428 hi Steven, I'm running python-3.4.2 on a linuxmint16 box and CANNOT reproduce it is just that int(i*x) == i is never True! hope that helps regards Michael * Steven D'Aprano [2015-07-02 16:56]: > 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 -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.3, with python-3.4.2, on linux mint 16 (petra) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!"