Subject: Re: bug#19025: 24.4; precision error when adding two floats

From: Alexis <[email-masked]>
Date: Wed, 12 Nov 2014 12:38:12 +1100

Kevin W. Currey writes:

> (message "%s" (+ 379.744 57.93))
>
> The above prints 437.67400000000004.  Same if I use 57.930, but if I use 57.931 (below) I get the correct answer 437.675.
>  
> (message "%s" (+ 379.744 57.931))
>
> I was able to work around by using format:
>  
> (message "%s" (format "%f" (+ 379.744 57.93)))
>
> which prints 437.674000.
>  
> FYI, I can replicate the issue with Emacs 21.3.1.

Isn't this an artifact of the nature of floating-point arithmetic, rather than
an issue with Emacs per se? For example, in Python:

    Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
    [GCC 4.7.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 379.744 + 57.93
    437.67400000000004

Alexis.