help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (+ 5.1 0.1)


From: Teemu Likonen
Subject: Re: (+ 5.1 0.1)
Date: Mon, 13 Jul 2009 15:59:10 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]