-nan is not number

For the Compleat Fan

-nan is not number

Postby ssqq » Mon Aug 01, 2016 8:56 am

-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.
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: -nan is not number

Postby TedWalther » Tue Aug 02, 2016 10:03 am

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.
TedWalther
 
Posts: 602
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: -nan is not number

Postby rickyboy » Tue Aug 02, 2016 12:22 pm

Hello ssqq,

This is what you need: http://www.newlisp.org/downloads/newlisp_manual.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)
rickyboy
 
Posts: 554
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: -nan is not number

Postby ssqq » Tue Aug 02, 2016 2:40 pm

I see, Reason is ANSI C could not support.
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm


Return to Anything else we might add?

Who is online

Users browsing this forum: No registered users and 2 guests

cron