GNU bug report logs -
#19025
24.4; precision error when adding two floats
Previous Next
Reported by: "Kevin W. Currey" <kevalier68 <at> hotmail.com>
Date: Wed, 12 Nov 2014 01:25:02 UTC
Severity: normal
Tags: notabug
Found in version 24.4
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
This bug report was last modified 10 years and 197 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.