unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jay Belanger <jay.p.belanger@gmail.com>
To: 19025@debbugs.gnu.org
Subject: bug#19025: 24.4; precision error when adding two floats
Date: Tue, 11 Nov 2014 20:28:49 -0600	[thread overview]
Message-ID: <87mw7xtan2.fsf@gmail.com> (raw)
In-Reply-To: <87oasd6vl4.fsf@gmail.com> (Alexis's message of "Wed, 12 Nov 2014 12:38:12 +1100")


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

Yes, although it probably wouldn't be a bad idea to point out this issue
in the Elisp documentation.






  reply	other threads:[~2014-11-12  2:28 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 [this message]
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=87mw7xtan2.fsf@gmail.com \
    --to=jay.p.belanger@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).