From: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Q on NaN
Date: Sat, 25 Jun 2005 00:03:41 +0200 [thread overview]
Message-ID: <u1x6rh0oy.fsf@gnu.org> (raw)
In-Reply-To: <DNEMKBNJBGPAOPIJOOICGELCCJAA.drew.adams@oracle.com>
> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Fri, 24 Jun 2005 13:26:23 -0700
>
> I didn't say above that (/0.0 0.0) should give `arith-error'.
Well, you seemed to: you complained that it did so in previous
versions.
> I suggested
> that perhaps `numberp' should return nil for a NaN argument, since "NaN"
> means "not a number" and "numberp" means "a number". NaN is a floating-point
> value, but is it a number?
Any floating-point value is a ``number'' as far as `numberp' is
concerned. The fact that NaN is a short for not-a-number does not
mean that Lisp should treat it like that.
> As for a way to test for a NaN, try this:
> (= (/ 0.0 0.0) (/ 0.0 0.0))
> It should evaluate to nil, since a NaN is defined to fail _any_
> arithmetic comparison, even a comparison to itself.
>
> That doesn't tell me how to test if `foobar' is a NaN.
Exactly the same: (= foobar foobar). (Did you try that?)
> See my previous
> email: I knew I could test `(equal foo 0.0e+Nan)', but I thought I would
> need to test against all of the possible NaN values.
No need: the arithmetic equality trick takes care of all of the
possible values. Note that you should use `=', not `equal' (nor
`eql', btw).
> BTW, here is something I didn't expect:
>
> `M-: 0.0e+NaN' returns -0.0e+NaN
> `M-: -0.0e+NaN' returns 0.0e+NaN
>
> The reader seems to flip the (irrelevant) sign.
I think it's not the reader, but the underlying library's printf
family.
next prev parent reply other threads:[~2005-06-24 22:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-24 19:06 Q on NaN Drew Adams
2005-06-24 19:33 ` Drew Adams
2005-06-24 19:46 ` Drew Adams
2005-06-24 21:01 ` Eli Zaretskii
2005-06-24 20:26 ` Drew Adams
2005-06-24 20:56 ` Gaëtan LEURENT
2005-06-24 20:59 ` Luc Teirlinck
2005-06-24 22:03 ` Eli Zaretskii [this message]
2005-06-24 21:49 ` Drew Adams
2005-06-24 22:31 ` Luc Teirlinck
2005-06-24 22:54 ` Drew Adams
2005-06-25 13:35 ` Richard M. Stallman
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=u1x6rh0oy.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@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).