SURFEX v8.1
General documentation of Surfex
ieee754.h
Go to the documentation of this file.
1 #undef __BYTE_ORDER
2 
3 #ifdef BIG_endian
4 # define __BYTE_ORDER 1234
5 #endif
6 #ifdef LITTLE_endian
7 # define __BYTE_ORDER 4321
8 #endif
9 #if !(defined(__BYTE_ORDER))
10  #error "ieee754.h : you MUST specify \
11 -DBIG_endian or -DLITTLE_endian \
12 in CPPFLAGS of your Makefile."
13 /* Compiler must throw us out at this point! */
14 #endif
15 
16 #define __BIG_ENDIAN 1234
17 #define __LITTLE_ENDIAN 4321
18 
20  {
21  double d;
22 
23  /* This is the IEEE 754 double-precision format. */
24  struct
25  {
26 #if __BYTE_ORDER == __BIG_ENDIAN
27  unsigned int negative:1;
28  unsigned int exponent:11;
29  /* Together these comprise the mantissa. */
30  unsigned int mantissa0:20;
31  unsigned int mantissa1:32;
32 #endif /* Big endian. */
33 #if __BYTE_ORDER == __LITTLE_ENDIAN
34  /* Together these comprise the mantissa. */
35  unsigned int mantissa1:32;
36  unsigned int mantissa0:20;
37  unsigned int exponent:11;
38  unsigned int negative:1;
39 #endif /* Little endian. */
40  } ieee;
41 
42  /* This format makes it easier to see if a NaN is a signalling NaN. */
43  struct
44  {
45 #if __BYTE_ORDER == __BIG_ENDIAN
46  unsigned int negative:1;
47  unsigned int exponent:11;
48  unsigned int quiet_nan:1;
49  /* Together these comprise the mantissa. */
50  unsigned int mantissa0:19;
51  unsigned int mantissa1:32;
52 #else
53  /* Together these comprise the mantissa. */
54  unsigned int mantissa1:32;
55  unsigned int mantissa0:19;
56  unsigned int quiet_nan:1;
57  unsigned int exponent:11;
58  unsigned int negative:1;
59 #endif
60  } ieee_nan;
61  };
62 
63 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
unsigned int mantissa1
Definition: ieee754.h:31
unsigned int negative
Definition: ieee754.h:27
unsigned int exponent
Definition: ieee754.h:28
unsigned int mantissa0
Definition: ieee754.h:30
struct ieee754_double::@2 ieee_nan
struct ieee754_double::@1 ieee
unsigned int quiet_nan
Definition: ieee754.h:48
double d
Definition: ieee754.h:21