netmsgs  1.2.2
RoadNarrows Robotics Network Messaging Package
cyg-ieee754.h
1 /* Copyright (C) 1992, 1995, 1996, 1998 Free Software Foundation, Inc.
2  This file is part of the GNU C Library.
3 
4  The GNU C Library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public License as
6  published by the Free Software Foundation; either version 2 of the
7  License, or (at your option) any later version.
8 
9  The GNU C Library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public
15  License along with the GNU C Library; see the file COPYING.LIB. If not,
16  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  Boston, MA 02111-1307, USA. */
18 
19 #ifndef _IEEE754_H
20 
21 #define _IEEE754_H 1
22 #include "features.h"
23 
24 #include "endian.h"
25 
26 __BEGIN_DECLS
27 
29  {
30  float f;
31 
32  /* This is the IEEE 754 single-precision format. */
33  struct
34  {
35  unsigned int mantissa:23;
36  unsigned int exponent:8;
37  unsigned int negative:1;
38  } ieee;
39 
40  /* This format makes it easier to see if a NaN is a signalling NaN. */
41  struct
42  {
43  unsigned int mantissa:22;
44  unsigned int quiet_nan:1;
45  unsigned int exponent:8;
46  unsigned int negative:1;
47  } ieee_nan;
48  };
49 
50 #define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
51 
52 
54  {
55  double d;
56 
57  /* This is the IEEE 754 double-precision format. */
58  struct
59  {
60  unsigned int mantissa0:20;
61  unsigned int exponent:11;
62  unsigned int negative:1;
63  unsigned int mantissa1:32;
64  } ieee;
65 
66  /* This format makes it easier to see if a NaN is a signalling NaN. */
67  struct
68  {
69  unsigned int mantissa0:19;
70  unsigned int quiet_nan:1;
71  unsigned int exponent:11;
72  unsigned int negative:1;
73  unsigned int mantissa1:32;
74  } ieee_nan;
75  };
76 
77 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
78 
79 
80 /* The following two structures are correct for `new' floating point systems but
81  wrong for the old FPPC. The only solution seems to be to avoid their use on
82  old hardware. */
83 
85  {
86  long double d;
87 
88  /* This is the IEEE 854 double-extended-precision format. */
89  struct
90  {
91  unsigned int exponent:15;
92  unsigned int empty:16;
93  unsigned int negative:1;
94  unsigned int mantissa1:32;
95  unsigned int mantissa0:32;
96  } ieee;
97 
98  /* This is for NaNs in the IEEE 854 double-extended-precision format. */
99  struct
100  {
101  unsigned int exponent:15;
102  unsigned int empty:16;
103  unsigned int negative:1;
104  unsigned int mantissa1:32;
105  unsigned int mantissa0:30;
106  unsigned int quiet_nan:1;
107  unsigned int one:1;
108  } ieee_nan;
109  };
110 
111 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
112 
113 __END_DECLS
114 
115 #endif /* ieee754.h */