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

From: "Kevin W. Currey" <[email-masked]>
Date: Tue, 11 Nov 2014 19:36:39 -0500

(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.
 
Thanks,
-Kevin

In GNU Emacs 24.4.1 (x86_64-unknown-cygwin)
 of 2014-10-21 on desktop-new
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure
 --srcdir=/home/kbrown/src/cygemacs/emacs-24.4-1.x86_64/src/emacs-24.4
 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
 --libexecdir=/usr/libexec --datadir=/usr/share --localstatedir=/var
 --sysconfdir=/etc --libdir=/usr/lib --datarootdir=/usr/share
 --docdir=/usr/share/doc/emacs --htmldir=/usr/share/doc/emacs/html -C
 --with-w32 --without-file-notification --enable-checking 'CFLAGS=-ggdb
 -O2 -pipe -Wimplicit-function-declaration -Og -g3
 -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.4-1.x86_64/build=/usr/src/debug/emacs-24.4-1
 -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.4-1.x86_64/src/emacs-24.4=/usr/src/debug/emacs-24.4-1'
 CPPFLAGS= LDFLAGS='

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  shell-dirtrack-mode: t
  display-time-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t

Recent messages:
Load-path shadows:
None found.

Features:
(pp shadow sort gnus-util mail-extr emacsbug message format-spec rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils info find-func grep tabify sh-script smie
executable shell pcomplete compile comint ansi-color ring dabbrev
cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs arc-mode archive-mode dired-aux ispell apropos
dired help-fns help-mode easymenu mule-util server edmacro kmacro
cl-loaddefs cl-lib time jka-compr time-date tooltip electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel w32-common-fns disp-table
w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind w32 multi-tty emacs)

Memory information:
((conses 16 145217 10616)
 (symbols 48 23227 0)
 (miscs 40 133 446)
 (strings 32 31064 5702)
 (string-bytes 1 930985)
 (vectors 16 15771)
 (vector-slots 8 452262 7494)
 (floats 8 82 775)
 (intervals 56 640 31)
 (buffers 960 24))