2 b2cfc4e2 2003-09-30 devnull * 64-bit IEEE not-a-number routines.
3 b2cfc4e2 2003-09-30 devnull * This is big/little-endian portable assuming that
4 b2cfc4e2 2003-09-30 devnull * the 64-bit doubles and 64-bit integers have the
5 b2cfc4e2 2003-09-30 devnull * same byte ordering.
8 b2cfc4e2 2003-09-30 devnull #include "nan.h"
10 b2cfc4e2 2003-09-30 devnull typedef unsigned long long uvlong;
11 b2cfc4e2 2003-09-30 devnull typedef unsigned long ulong;
13 b2cfc4e2 2003-09-30 devnull #ifdef NEEDLL
14 b2cfc4e2 2003-09-30 devnull static uvlong uvnan = 0x7FF0000000000001LL;
15 b2cfc4e2 2003-09-30 devnull static uvlong uvinf = 0x7FF0000000000000LL;
16 b2cfc4e2 2003-09-30 devnull static uvlong uvneginf = 0xFFF0000000000000LL;
18 b2cfc4e2 2003-09-30 devnull static uvlong uvnan = 0x7FF0000000000001;
19 b2cfc4e2 2003-09-30 devnull static uvlong uvinf = 0x7FF0000000000000;
20 b2cfc4e2 2003-09-30 devnull static uvlong uvneginf = 0xFFF0000000000000;
24 b2cfc4e2 2003-09-30 devnull __NaN(void)
26 b2cfc4e2 2003-09-30 devnull uvlong *p;
28 b2cfc4e2 2003-09-30 devnull /* gcc complains about "return *(double*)&uvnan;" */
29 b2cfc4e2 2003-09-30 devnull p = &uvnan;
30 b2cfc4e2 2003-09-30 devnull return *(double*)p;
34 b2cfc4e2 2003-09-30 devnull __isNaN(double d)
36 b2cfc4e2 2003-09-30 devnull uvlong x;
37 b2cfc4e2 2003-09-30 devnull double *p;
40 b2cfc4e2 2003-09-30 devnull x = *(uvlong*)p;
41 b2cfc4e2 2003-09-30 devnull return (ulong)(x>>32)==0x7FF00000 && !__isInf(d, 0);
45 b2cfc4e2 2003-09-30 devnull __Inf(int sign)
47 b2cfc4e2 2003-09-30 devnull uvlong *p;
49 b2cfc4e2 2003-09-30 devnull if(sign < 0)
50 b2cfc4e2 2003-09-30 devnull p = &uvinf;
52 b2cfc4e2 2003-09-30 devnull p = &uvneginf;
53 b2cfc4e2 2003-09-30 devnull return *(double*)p;
57 b2cfc4e2 2003-09-30 devnull __isInf(double d, int sign)
59 b2cfc4e2 2003-09-30 devnull uvlong x;
60 b2cfc4e2 2003-09-30 devnull double *p;
63 b2cfc4e2 2003-09-30 devnull x = *(uvlong*)p;
64 b2cfc4e2 2003-09-30 devnull if(sign == 0)
65 b2cfc4e2 2003-09-30 devnull return x==uvinf || x==uvneginf;
66 b2cfc4e2 2003-09-30 devnull else if(sign > 0)
67 b2cfc4e2 2003-09-30 devnull return x==uvinf;
69 b2cfc4e2 2003-09-30 devnull return x==uvneginf;