Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; '(python': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'reports.': 0.09; 'subject:skip:m 10': 0.09; 'python': 0.11; '2.7': 0.13; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reproduce': 0.16; 'wrote:': 0.16; 'do.': 0.22; 'produces': 0.22; 'title,': 0.22; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'convert': 0.29; "can't": 0.32; 'anyone': 0.32; 'probably': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'to:addr:python-list': 0.35; 'so,': 0.37; 'operating': 0.37; 'subject:: ': 0.37; 'version': 0.38; 'received:org': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'system.': 0.39; 'your': 0.60; 'more': 0.62; 'reply': 0.67; 'stated': 0.70; 'received:109': 0.75; '2.7.8': 0.84; 'becker': 0.84; 'succeeds': 0.84; '2014,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robin Becker Subject: Re: Bug in floating point multiplication Date: Thu, 02 Jul 2015 16:24:29 +0100 References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 109.174.168.73 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435850672 news.xs4all.nl 2926 [2001:888:2000:d::a6]:46779 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93430 On 02/07/2015 15:52, Steven D'Aprano 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 ... as stated the above fails since it produces x==1L for python 2.7 (Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.) If I convert old style x = 1.0 - 1.0/2**53 then the assertion succeeds and the loop does not print. -- Robin Becker