libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / libroot / posix / glibc / include / ieee754.h
blob7131e5de6cc5d537ecd59a3952e10fac7fb07ca5
1 /* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifndef _IEEE754_H
21 #define _IEEE754_H 1
22 #include <features.h>
24 #include <endian.h>
26 __BEGIN_DECLS
28 union ieee754_float
30 float f;
32 /* This is the IEEE 754 single-precision format. */
33 struct
35 #if __BYTE_ORDER == __BIG_ENDIAN
36 unsigned int negative:1;
37 unsigned int exponent:8;
38 unsigned int mantissa:23;
39 #endif /* Big endian. */
40 #if __BYTE_ORDER == __LITTLE_ENDIAN
41 unsigned int mantissa:23;
42 unsigned int exponent:8;
43 unsigned int negative:1;
44 #endif /* Little endian. */
45 } ieee;
47 /* This format makes it easier to see if a NaN is a signalling NaN. */
48 struct
50 #if __BYTE_ORDER == __BIG_ENDIAN
51 unsigned int negative:1;
52 unsigned int exponent:8;
53 unsigned int quiet_nan:1;
54 unsigned int mantissa:22;
55 #endif /* Big endian. */
56 #if __BYTE_ORDER == __LITTLE_ENDIAN
57 unsigned int mantissa:22;
58 unsigned int quiet_nan:1;
59 unsigned int exponent:8;
60 unsigned int negative:1;
61 #endif /* Little endian. */
62 } ieee_nan;
65 #define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
68 union ieee754_double
70 double d;
72 /* This is the IEEE 754 double-precision format. */
73 struct
75 #if __BYTE_ORDER == __BIG_ENDIAN
76 unsigned int negative:1;
77 unsigned int exponent:11;
78 /* Together these comprise the mantissa. */
79 unsigned int mantissa0:20;
80 unsigned int mantissa1:32;
81 #endif /* Big endian. */
82 #if __BYTE_ORDER == __LITTLE_ENDIAN
83 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
84 unsigned int mantissa0:20;
85 unsigned int exponent:11;
86 unsigned int negative:1;
87 unsigned int mantissa1:32;
88 # else
89 /* Together these comprise the mantissa. */
90 unsigned int mantissa1:32;
91 unsigned int mantissa0:20;
92 unsigned int exponent:11;
93 unsigned int negative:1;
94 # endif
95 #endif /* Little endian. */
96 } ieee;
98 /* This format makes it easier to see if a NaN is a signalling NaN. */
99 struct
101 #if __BYTE_ORDER == __BIG_ENDIAN
102 unsigned int negative:1;
103 unsigned int exponent:11;
104 unsigned int quiet_nan:1;
105 /* Together these comprise the mantissa. */
106 unsigned int mantissa0:19;
107 unsigned int mantissa1:32;
108 #else
109 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
110 unsigned int mantissa0:19;
111 unsigned int quiet_nan:1;
112 unsigned int exponent:11;
113 unsigned int negative:1;
114 unsigned int mantissa1:32;
115 # else
116 /* Together these comprise the mantissa. */
117 unsigned int mantissa1:32;
118 unsigned int mantissa0:19;
119 unsigned int quiet_nan:1;
120 unsigned int exponent:11;
121 unsigned int negative:1;
122 # endif
123 #endif
124 } ieee_nan;
127 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
130 union ieee854_long_double
132 long double d;
134 /* This is the IEEE 854 double-extended-precision format. */
135 struct
137 #if __BYTE_ORDER == __BIG_ENDIAN
138 unsigned int negative:1;
139 unsigned int exponent:15;
140 unsigned int empty:16;
141 unsigned int mantissa0:32;
142 unsigned int mantissa1:32;
143 #endif
144 #if __BYTE_ORDER == __LITTLE_ENDIAN
145 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
146 unsigned int exponent:15;
147 unsigned int negative:1;
148 unsigned int empty:16;
149 unsigned int mantissa0:32;
150 unsigned int mantissa1:32;
151 # else
152 unsigned int mantissa1:32;
153 unsigned int mantissa0:32;
154 unsigned int exponent:15;
155 unsigned int negative:1;
156 unsigned int empty:16;
157 # endif
158 #endif
159 } ieee;
161 /* This is for NaNs in the IEEE 854 double-extended-precision format. */
162 struct
164 #if __BYTE_ORDER == __BIG_ENDIAN
165 unsigned int negative:1;
166 unsigned int exponent:15;
167 unsigned int empty:16;
168 unsigned int one:1;
169 unsigned int quiet_nan:1;
170 unsigned int mantissa0:30;
171 unsigned int mantissa1:32;
172 #endif
173 #if __BYTE_ORDER == __LITTLE_ENDIAN
174 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
175 unsigned int exponent:15;
176 unsigned int negative:1;
177 unsigned int empty:16;
178 unsigned int mantissa0:30;
179 unsigned int quiet_nan:1;
180 unsigned int one:1;
181 unsigned int mantissa1:32;
182 # else
183 unsigned int mantissa1:32;
184 unsigned int mantissa0:30;
185 unsigned int quiet_nan:1;
186 unsigned int one:1;
187 unsigned int exponent:15;
188 unsigned int negative:1;
189 unsigned int empty:16;
190 # endif
191 #endif
192 } ieee_nan;
195 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
197 __END_DECLS
199 #endif /* ieee754.h */