From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Kevin W. Currey" <kevalier68@hotmail.com>
Cc: 19025-done@debbugs.gnu.org
Subject: bug#19025: 24.4; precision error when adding two floats
Date: Tue, 11 Nov 2014 21:06:35 -0500 [thread overview]
Message-ID: <jwvk3319o39.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <BLU173-W24D13BED05558CB0C7562CCA8E0@phx.gbl> (Kevin W. Currey's message of "Tue, 11 Nov 2014 19:36:39 -0500")
tags 19025 notabug
thanks
> (message "%s" (+ 379.744 57.93))
> The above prints 437.67400000000004.
That's the difference between floating-point numbers and real or
rational numbers.
> (message "%s" (format "%f" (+ 379.744 57.93)))
You can cut the middle man: (message "%f" (+ 379.744 57.93))
But note that this prints something "incorrect":
M-: (message "%f" (+ 379.744 57.93))
=> 437.674000.
M-: (equal (+ 379.744 57.93) 437.674000)
=> nil
It's just that %f rounds differently.
Stefan
prev parent reply other threads:[~2014-11-12 2:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvk3319o39.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=19025-done@debbugs.gnu.org \
--cc=kevalier68@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).