Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'languages,': 0.04; 'subject:bug': 0.07; '0.02': 0.09; '0.1': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'python': 0.11; 'bug': 0.12; '0.01': 0.16; '0.03': 0.16; '0.04': 0.16; '0.06': 0.16; '0.07': 0.16; '0.09': 0.16; '0.19': 0.16; 'url:ftp': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'install': 0.23; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'compare': 0.26; 'received:(smtp server)': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; "i'm": 0.30; 'code': 0.31; 'gary': 0.31; 'there.': 0.32; 'url:python': 0.33; 'limitation': 0.33; 'no,': 0.35; 'but': 0.35; 'there': 0.35; 'crazy': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'details.': 0.61; 'first': 0.61; 'more': 0.64; 'url:4': 0.69; 'computers.': 0.84 X-Virus-Scanned: OK Date: Fri, 20 Jun 2014 18:07:58 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: python 3.44 float addition bug? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403313432 news.xs4all.nl 2905 [2001:888:2000:d::a6]:58197 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73473 On 06/20/2014 05:57 PM, FraserL wrote: > I think I found a strange bug in python 3.4.1, No, this is not a bug in Python. There is a limitation of floating point arithmetic in *all* languages, on *all* computers. Python 3 may be the first to let you see this limitation, but it's always been there. See https://docs.python.org/2/tutorial/floatingpoint.html for more details. Gary Herron > > fresh install of > > https://www.python.org/ftp/python/3.4.1/python-3.4.1.amd64.msi > > and a fresh install of > https://www.python.org/ftp/python/2.7.7/python-2.7.7.amd64.msi > to compare it to. > > #test code > z = 0.01 > p = 0.0 > for x, y in enumerate(range(1, 20)): > p += z > print(p) > #end > > > 3.4.1 output: > > 0.01 > 0.02 > 0.03 > 0.04 > 0.05 > 0.060000000000000005 > 0.07 > 0.08 > 0.09 > 0.09999999999999999 > 0.10999999999999999 > 0.11999999999999998 > 0.12999999999999998 > 0.13999999999999999 > 0.15 > 0.16 > 0.17 > 0.18000000000000002 > 0.19000000000000003 > > > 2.7.7 output: > > 0.01 > 0.02 > 0.03 > 0.04 > 0.05 > 0.06 > 0.07 > 0.08 > 0.09 > 0.1 > 0.11 > 0.12 > 0.13 > 0.14 > 0.15 > 0.16 > 0.17 > 0.18 > 0.19 > > > I'm not hugely accustomed to Python, but this seems crazy to me.