emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q on NaN


From: Eli Zaretskii
Subject: Re: Q on NaN
Date: Sat, 25 Jun 2005 00:03:41 +0200

> From: "Drew Adams" <address@hidden>
> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]