NAN code

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: hackers(at)postgreSQL(dot)org (PostgreSQL-development)
Subject: NAN code
Date: 1999-01-01 04:23:48
Message-ID: 199901010423.XAA26089@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-01-01 04:50:31 Re: 2 patches
Previous Message Bruce Momjian 1999-01-01 04:16:28 NAN code