From: Alexis <flexibeast@gmail.com>
To: 19025@debbugs.gnu.org
Subject: bug#19025: 24.4; precision error when adding two floats
Date: Wed, 12 Nov 2014 12:38:12 +1100 [thread overview]
Message-ID: <87oasd6vl4.fsf@gmail.com> (raw)
In-Reply-To: <BLU173-W24D13BED05558CB0C7562CCA8E0@phx.gbl>
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.
next prev parent reply other threads:[~2014-11-12 1:38 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 [this message]
2014-11-12 2:28 ` Jay Belanger
2014-11-12 2:42 ` Alexis
2014-11-12 2:06 ` Stefan Monnier
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=87oasd6vl4.fsf@gmail.com \
--to=flexibeast@gmail.com \
--cc=19025@debbugs.gnu.org \
/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).