emacs-devel
[Top][All Lists]
Advanced

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

Q on NaN


From: Drew Adams
Subject: Q on NaN
Date: Fri, 24 Jun 2005 12:06:15 -0700

Consider this:

(condition-case nil (setq foo (/ 0.0 0.0)) (arith-error nil))

In older versions of Emacs (at least prior to April 2005 CVS), this would
evaluate to nil. Now, it evaluates to -0.0NaN (on Windows, at least), which
breaks the encompassing code (which tests the above expression for non-nil).

Fair enough. I can modify the code like so:

(and (condition-case nil (setq foo (/ 0.0 0.0)) (arith-error nil))
     (bar foo)) ; foo must be a number, not a NaN

What function do I use for bar?

`numberp' doesn't work, since (numberp -0.0NaN) is non-nil. That seems odd
to me, since NaN means "not a number" and numberp means "a number", but I
guess I can live with a little oddness.

In the Elisp manual, I didn't find a predicate to test for NaN.





reply via email to

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