Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin1!goblin2!goblin.stu.neva.ru!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.052 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.02; 'subject:Python': 0.05; 'python': 0.08; '>>>>': 0.09; 'bug?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:95': 0.09; '18:13,': 0.16; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.22; 'math': 0.24; 'skip:1 30': 0.29; 'subject: .': 0.29; 'thanks': 0.32; 'there': 0.33; 'header :User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'from:addr:yahoo.co.uk': 0.34; 'numbers.': 0.34; 'to:addr:python- list': 0.35; 'google': 0.35; 'received:org': 0.36; 'mathematical': 0.38; 'point': 0.40; 'to:addr:python.org': 0.40; 'url:%0': 0.60; 'simple': 0.61; 'taylor': 0.67; 'url:%2b': 0.67; 'url:i': 0.74; 'received:as13285.net': 0.84; 'url:530': 0.84; 'url:74': 0.84; 'aka': 0.91; 'received:2': 0.91; 'only:': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Python math is off by .000000000000045 Date: Wed, 22 Feb 2012 18:24:37 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-97-68-111.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: X-Antivirus: avast! (VPS 120222-0, 22/02/2012), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329935101 news.xs4all.nl 6905 [2001:888:2000:d::a6]:41065 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20690 On 22/02/2012 18:13, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor Please google for floating point numbers. -- Cheers. Mark Lawrence.