[racket-dev] Equality test for Not-A-Number

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Wed Oct 27 18:36:24 EDT 2010

I found in the reference manual that eqv? works for NANs. I assume that eqv?
or = would both work on infinities. Here again, the science collection uses
eqv? for both infinities and NANs - so I may have discussed this with you
years ago when I originally wrote them. But I do think that adding explicit
nan?, infinite?, and finite? (which is not the same as (not (infinite? x)
because of NANs) would be a good idea at some point to reduce the confusion
as to what equality operator to use.

On Wed, Oct 27, 2010 at 4:18 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Wed, 27 Oct 2010 14:20:37 -0600, Doug Williams wrote:
> > What is the correct way to test for +nan.0 in Racket? For example, (=
> +nan.0
> > +nan.0) = #f. This seems to be the behavior specified in R6RS. In the
> > science collection I implemented nan? using eqv?, which seems to work in
> > Racket; but the result is explicitly unspecified in R6RS, which I assume
> > means that it's up to the implementation. Which pretty much leaves eq? as
> > the proper test. R6RS includes primitives like nan? and infinite?, which
> I
> > included a long time ago in the science collection. Obviously one can use
> > them from the r6rs libraries, but should they be moved into the racket
> > language?
> `eq?' will not work, while Racket (unlike R6RS) promises that `eqv?'
> will work.
> At Wed, 27 Oct 2010 15:15:44 -0700, David Herman wrote:
> > Does (not (= x x)) work?
> Yes, that would work too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20101027/d1536c31/attachment.html>

Posted on the dev mailing list.