File: NaN.h.in

package info (click to toggle)
funtools 1.4.4+dfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,168 kB
  • ctags: 10,760
  • sloc: ansic: 87,238; sh: 9,727; lex: 4,595; asm: 3,281; ada: 1,681; makefile: 1,458; pascal: 1,089; cpp: 1,001; cs: 879; perl: 161; yacc: 64; sed: 32; csh: 10; tcl: 9
file content (70 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *	Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
 */

/*
 *
 * NaN.h -- include file to deal with IEEE NaN values
 *
 * Idea taken from fitsio2.h in the cfitsio package by William Pence (HEASARC),
 * to whom grateful acknowledgement is made.
 *
 * These functions tests whether the float value is a reserved IEEE
 * value such as a Not-a-Number (NaN), or underflow, overflow, or
 * infinity.   The functions returns 1 if the value is a NaN, overflow
 * or infinity; otherwise it returns 0.
 *
 * isnanf tests floats, isnand tests doubles.
 *
 */
#ifndef	__nan_h
#define	__nan_h

#include "prsetup.h"

#define BIGENDIAN @BIGENDIAN@

#if BIGENDIAN

#define FNANOFF 0
#define DNANOFF 0

#else

#define FNANOFF 1
#define DNANOFF 3

#endif

#define FNANMASK   0x7F80 /* mask bits 1 - 8; all set on NaNs */
                                     /* all 0 on underflow  or 0. */
 
#define DNANMASK   0x7FF0 /* mask bits 1 - 11; all set on NaNs */
                                     /* all 0 on underflow  or 0. */
 
#ifndef isnanf
typedef union {
  float f; 
  short x[2];
} uffu;

#define isnanf(X) ((((uffu*)&X)->x[FNANOFF] & FNANMASK) == FNANMASK)
#endif

#ifndef isnand
typedef union {
  double d;
  short x[4];
} uddu;

#define isnand(X) ((((uddu*)&X)->x[DNANOFF] & DNANMASK) == DNANMASK)
#endif
 
_PRbeg

float  getnanf _PRx((void));
double getnand _PRx((void));

_PRend

#endif