From: James Clark <jjc@jclark.com>
Subject: NaN and equal
Date: Wed, 13 Aug 2003 08:24:10 +0700 [thread overview]
Message-ID: <3F39933A.9090807@jclark.com> (raw)
With Emacs 21.3.1, i686-pc-linux-gnu
(equal 0.0e+NaN 0.0e+NaN)
returns nil. This does not seem consistent with the documentation of
equal. I would suggest that (= 0.0e+NaN 0.0e+NaN) continues to return
nil, for consistency with the IEEE floating point standard (which of
course says that NaN != NaN), but that (equal 0.0e+NaN 0.0e+NaN) return
t, so that hash-tables and alists with NaN can work.
Here's a patch. I don't think this should cause any problems on systems
without NaN.
*** /home/jjc/var/build/emacs-21.3/src/fns.c~ 2002-12-04
19:38:32.000000000 +0700
--- /home/jjc/var/build/emacs-21.3/src/fns.c 2003-08-12
23:04:52.000000000 +0700
***************
*** 1976,1982 ****
switch (XTYPE (o1))
{
case Lisp_Float:
! return (extract_float (o1) == extract_float (o2));
case Lisp_Cons:
if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1))
--- 1976,1990 ----
switch (XTYPE (o1))
{
case Lisp_Float:
! {
! double d1, d2;
!
! d1 = extract_float (o1);
! d2 = extract_float (o2);
! /* If d is NaN, then d != d. Two NaNs should be equal
! even though they are not =. */
! return d1 == d2 || (d1 != d1 && d2 != d2);
! }
case Lisp_Cons:
if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1))
James
reply other threads:[~2003-08-13 1:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F39933A.9090807@jclark.com \
--to=jjc@jclark.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 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.