NAN code

Started by Bruce Momjianover 27 years ago1 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

I have found a way to assign NAN to a variable, thanks to the library
source code. Is this better than the code I just posted? Looks pretty
platform-specific, and we may be better with my earlier code to just use
num, which I have committed to the CURRENT tree.

The strange thing is that isnan(0/0) generates a floating-pointer error
and stops the program, but this does not. Strange.

---------------------------------------------------------------------------

#include <stdio.h>
#include <math.h>

main()
{
double x;
x = 3;

if (isnan((x-x)/(x-x)))
printf("nan\n");
else
printf("not nan\n");
}

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026