From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: (+ 5.1 0.1) Date: Mon, 13 Jul 2009 15:59:10 +0300 Organization: A noiseless patient Spider Message-ID: <87hbxg3fj5.fsf@iki.fi> References: <44632093-47cc-4907-bfa0-a3202f51657d@q40g2000prh.googlegroups.com> <874otgdb9q.wl%anselm.helbig+news2009@googlemail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1247493600 10835 80.91.229.12 (13 Jul 2009 14:00:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Jul 2009 14:00:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 13 15:59:53 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQM4N-0008FU-B5 for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Jul 2009 15:59:51 +0200 Original-Received: from localhost ([127.0.0.1]:45142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQM4M-0001PA-RU for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Jul 2009 09:59:50 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!news.glorb.com!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 Original-X-Trace: news.eternal-september.org U2FsdGVkX1+Q03DtziH2qtWhR1InnqOZo97tmvv+GXEdqUfkrQU6uySwQNnxPTtkVNs71jHYNUfuJh781BAuZ3bAdCnNHMND7WN1vTtS5F3aequn1htqlp8IbSuoejMNXAuzyvOr83oiAx0gKDhnS4dyRp0wxW37 Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Mon, 13 Jul 2009 13:04:33 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1913ROOqqq1ivshOzh9fF+pAKoRLznE1y5lrmQWZMZd0A== Cancel-Lock: sha1:UoCOTOu2dqpP7bb4CsmOIZwbUfM= sha1:tVoDOJCeOzuwpNq7DmlvoIyzg+U= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:170829 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:66026 Archived-At: On 2009-07-13 14:21 (+0200), Anselm Helbig wrote: > This is a fundamental problem with floating point numbers, something > similar happens in python: > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> 5.1 + 0.1 > 5.1999999999999993 Thanks for info. This is new to me too as I don't know much about floating point numbers. For that particular example CLISP, a Common Lisp implementation, gives the correct result: $ clisp -q -norc -x '(+ 5.1 0.1)' 5.2 Emacs' arbitrary-precision calculator gives 5.2 too: (calc-eval "5.1 + 0.1") => "5.2" > http://www.theregister.co.uk/2006/08/12/floating_point_approximation/ > http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems I'll certainly study these.