all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19025: 24.4; precision error when adding two floats
@ 2014-11-12  0:36 Kevin W. Currey
  2014-11-12  1:38 ` Alexis
  2014-11-12  2:06 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Kevin W. Currey @ 2014-11-12  0:36 UTC (permalink / raw)
  To: 19025

[-- Attachment #1: Type: text/plain, Size: 3368 bytes --]

(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))

 		 	   		  

[-- Attachment #2: Type: text/html, Size: 4016 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-12  2:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12  0:36 bug#19025: 24.4; precision error when adding two floats Kevin W. Currey
2014-11-12  1:38 ` Alexis
2014-11-12  2:28   ` Jay Belanger
2014-11-12  2:42     ` Alexis
2014-11-12  2:06 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.