-nan is not number

For the Compleat Fan
Post Reply
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

-nan is not number

Post by ssqq »

-nan (NaN) should not return true with number?

Code: Select all

> (set 'nan (sqrt -1))
> (number? nan)
true ;; should return nil
Also advise with inf. I think all NaN and Inf are "error status" that may not throw error immediatly.
So they isn't value.

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: -nan is not number

Post by TedWalther »

ssqq wrote:-nan (NaN) should not return true with number?

Code: Select all

> (set 'nan (sqrt -1))
> (number? nan)
true ;; should return nil
Also advise with inf. I think all NaN and Inf are "error status" that may not throw error immediatly.
So they isn't value.
Reliably getting nan and inf from the C compiler is not pleasant. It varies between compilers and architectures and platforms. The alternative is to write assembly language... which would really require some paid resources to keep track of all the different types of CPU.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

rickyboy
Posts: 596
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: -nan is not number

Post by rickyboy »

Hello ssqq,

This is what you need: http://www.newlisp.org/downloads/newlis ... .html#NaNp.

As a backgrounder, the committee who put together the floating point standard had a reason for admitting things like NaN as floating point "values". Technically they are "numbers" (FP values, really).

http://grouper.ieee.org/groups/754/faq.html#exceptions
(λx. x x) (λx. x x)

ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: -nan is not number

Post by ssqq »

I see, Reason is ANSI C could not support.

Post Reply