[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Q on NaN
From: |
Drew Adams |
Subject: |
RE: Q on NaN |
Date: |
Fri, 24 Jun 2005 12:46:43 -0700 |
Still following up on my own post:
(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.
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.
To make the point simpler:
(numberp (/0.0 0.0)) returns t. That seems like a bug to me.
If this is not considered a bug, and `numberp' should return non-nil for
NaN, as it currently does, then what are all the possible NaN values to
test?
The Elisp manual mentions that the read syntax for (/ 0.0 0.0) is 0.0e+NaN.
On my system it is in fact -0.0e+NaN. Are there additional NaN values, or
would this be a sufficient test for NaN-ness, to replace `numberp':
(let ((foo (/0.0 0.0)))
(and (not (equal -0.0e+NaN foo)) (not (equal 0.0e+NaN foo))))
(Note that (= -0.0e+NaN foo) returns nil, while (equal -0.0e+NaN foo)
returns `t'.)
- RE: Q on NaN, (continued)
- RE: Q on NaN, Drew Adams, 2005/06/24
- Re: Q on NaN, Eli Zaretskii, 2005/06/24
- RE: Q on NaN, Drew Adams, 2005/06/24
- Re: Q on NaN, Luc Teirlinck, 2005/06/24
- Re: Q on NaN, Gaƫtan LEURENT, 2005/06/24
- Re: Q on NaN, Eli Zaretskii, 2005/06/24
- RE: Q on NaN, Drew Adams, 2005/06/24
- Re: Q on NaN, Luc Teirlinck, 2005/06/24
- RE: Q on NaN, Drew Adams, 2005/06/24
- Re: Q on NaN, Richard M. Stallman, 2005/06/25
RE: Q on NaN,
Drew Adams <=