Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Serious error in int() function? Date: Wed, 13 Apr 2016 10:03 +0200 Organization: None Lines: 23 Message-ID: References: <52f7516c-8601-4252-ab16-bc30c59c8306@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de yUnaIrWzI/CJTwZ6Z8z6/QcYX1Hc214YQZKTDVY8Htwg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'subject:error': 0.11; "computer's": 0.16; 'hardware.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'ubuntu.': 0.16; 'wrote:': 0.16; 'language': 0.19; 'function:': 0.22; 'gcc': 0.22; "python's": 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'linux': 0.26; 'supported': 0.27; 'error': 0.27; 'yields': 0.29; 'print': 0.30; 'point': 0.33; 'url:python': 0.33; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; 'email addr:gmail.com': 0.62; 'url:tutorial': 0.91; 'serious': 0.97 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd8268.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <52f7516c-8601-4252-ab16-bc30c59c8306@googlegroups.com> Xref: csiph.com comp.lang.python:106928 martin.spichty@gmail.com wrote: > Hi, > > there may be a serious error in python's int() function: > > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! > > I am using Python Python 2.7.6, GCC 4.8.2 on Linux Ubuntu. > > Is that known? Yes. C has the same error as has every other language that uses the floating point numbers supported by your computer's hardware. See https://docs.python.org/2/tutorial/floatingpoint.html