Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / mips / ieee754 / ieee754.h
blobd50f282dd1534f806d64134249828e4b8de775b7
1 /* Copyright (C) 1992-2014 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, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _IEEE754_H
20 #define _IEEE754_H 1
21 #include <features.h>
23 #include <endian.h>
25 #include <float.h>
27 __BEGIN_DECLS
29 union ieee754_float
31 float f;
33 /* This is the IEEE 754 single-precision format. */
34 struct
36 #if __BYTE_ORDER == __BIG_ENDIAN
37 unsigned int negative:1;
38 unsigned int exponent:8;
39 unsigned int mantissa:23;
40 #endif /* Big endian. */
41 #if __BYTE_ORDER == __LITTLE_ENDIAN
42 unsigned int mantissa:23;
43 unsigned int exponent:8;
44 unsigned int negative:1;
45 #endif /* Little endian. */
46 } ieee;
48 /* This format makes it easier to see if a NaN is a signalling NaN. */
49 struct
51 #if __BYTE_ORDER == __BIG_ENDIAN
52 unsigned int negative:1;
53 unsigned int exponent:8;
54 unsigned int quiet_nan:1;
55 unsigned int mantissa:22;
56 #endif /* Big endian. */
57 #if __BYTE_ORDER == __LITTLE_ENDIAN
58 unsigned int mantissa:22;
59 unsigned int quiet_nan:1;
60 unsigned int exponent:8;
61 unsigned int negative:1;
62 #endif /* Little endian. */
63 } ieee_nan;
66 #define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
69 union ieee754_double
71 double d;
73 /* This is the IEEE 754 double-precision format. */
74 struct
76 #if __BYTE_ORDER == __BIG_ENDIAN
77 unsigned int negative:1;
78 unsigned int exponent:11;
79 /* Together these comprise the mantissa. */
80 unsigned int mantissa0:20;
81 unsigned int mantissa1:32;
82 #endif /* Big endian. */
83 #if __BYTE_ORDER == __LITTLE_ENDIAN
84 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
85 unsigned int mantissa0:20;
86 unsigned int exponent:11;
87 unsigned int negative:1;
88 unsigned int mantissa1:32;
89 # else
90 /* Together these comprise the mantissa. */
91 unsigned int mantissa1:32;
92 unsigned int mantissa0:20;
93 unsigned int exponent:11;
94 unsigned int negative:1;
95 # endif
96 #endif /* Little endian. */
97 } ieee;
99 /* This format makes it easier to see if a NaN is a signalling NaN. */
100 struct
102 #if __BYTE_ORDER == __BIG_ENDIAN
103 unsigned int negative:1;
104 unsigned int exponent:11;
105 unsigned int quiet_nan:1;
106 /* Together these comprise the mantissa. */
107 unsigned int mantissa0:19;
108 unsigned int mantissa1:32;
109 #else
110 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
111 unsigned int mantissa0:19;
112 unsigned int quiet_nan:1;
113 unsigned int exponent:11;
114 unsigned int negative:1;
115 unsigned int mantissa1:32;
116 # else
117 /* Together these comprise the mantissa. */
118 unsigned int mantissa1:32;
119 unsigned int mantissa0:19;
120 unsigned int quiet_nan:1;
121 unsigned int exponent:11;
122 unsigned int negative:1;
123 # endif
124 #endif
125 } ieee_nan;
128 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
130 #if LDBL_MANT_DIG == 113
132 union ieee854_long_double
134 long double d;
136 /* This is the IEEE 854 quad-precision format. */
137 struct
139 #if __BYTE_ORDER == __BIG_ENDIAN
140 unsigned int negative:1;
141 unsigned int exponent:15;
142 /* Together these comprise the mantissa. */
143 unsigned int mantissa0:16;
144 unsigned int mantissa1:32;
145 unsigned int mantissa2:32;
146 unsigned int mantissa3:32;
147 #endif /* Big endian. */
148 #if __BYTE_ORDER == __LITTLE_ENDIAN
149 /* Together these comprise the mantissa. */
150 unsigned int mantissa3:32;
151 unsigned int mantissa2:32;
152 unsigned int mantissa1:32;
153 unsigned int mantissa0:16;
154 unsigned int exponent:15;
155 unsigned int negative:1;
156 #endif /* Little endian. */
157 } ieee;
159 /* This format makes it easier to see if a NaN is a signalling NaN. */
160 struct
162 #if __BYTE_ORDER == __BIG_ENDIAN
163 unsigned int negative:1;
164 unsigned int exponent:15;
165 unsigned int quiet_nan:1;
166 /* Together these comprise the mantissa. */
167 unsigned int mantissa0:15;
168 unsigned int mantissa1:32;
169 unsigned int mantissa2:32;
170 unsigned int mantissa3:32;
171 #endif /* Big endian. */
172 #if __BYTE_ORDER == __LITTLE_ENDIAN
173 /* Together these comprise the mantissa. */
174 unsigned int mantissa3:32;
175 unsigned int mantissa2:32;
176 unsigned int mantissa1:32;
177 unsigned int mantissa0:15;
178 unsigned int quiet_nan:1;
179 unsigned int exponent:15;
180 unsigned int negative:1;
181 #endif /* Little endian. */
182 } ieee_nan;
185 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff /* Added to exponent. */
187 #elif LDBL_MANT_DIG == 64
189 union ieee854_long_double
191 long double d;
193 /* This is the IEEE 854 double-extended-precision format. */
194 struct
196 #if __BYTE_ORDER == __BIG_ENDIAN
197 unsigned int negative:1;
198 unsigned int exponent:15;
199 unsigned int empty:16;
200 unsigned int mantissa0:32;
201 unsigned int mantissa1:32;
202 #endif
203 #if __BYTE_ORDER == __LITTLE_ENDIAN
204 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
205 unsigned int exponent:15;
206 unsigned int negative:1;
207 unsigned int empty:16;
208 unsigned int mantissa0:32;
209 unsigned int mantissa1:32;
210 # else
211 unsigned int mantissa1:32;
212 unsigned int mantissa0:32;
213 unsigned int exponent:15;
214 unsigned int negative:1;
215 unsigned int empty:16;
216 # endif
217 #endif
218 } ieee;
220 /* This is for NaNs in the IEEE 854 double-extended-precision format. */
221 struct
223 #if __BYTE_ORDER == __BIG_ENDIAN
224 unsigned int negative:1;
225 unsigned int exponent:15;
226 unsigned int empty:16;
227 unsigned int one:1;
228 unsigned int quiet_nan:1;
229 unsigned int mantissa0:30;
230 unsigned int mantissa1:32;
231 #endif
232 #if __BYTE_ORDER == __LITTLE_ENDIAN
233 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
234 unsigned int exponent:15;
235 unsigned int negative:1;
236 unsigned int empty:16;
237 unsigned int mantissa0:30;
238 unsigned int quiet_nan:1;
239 unsigned int one:1;
240 unsigned int mantissa1:32;
241 # else
242 unsigned int mantissa1:32;
243 unsigned int mantissa0:30;
244 unsigned int quiet_nan:1;
245 unsigned int one:1;
246 unsigned int exponent:15;
247 unsigned int negative:1;
248 unsigned int empty:16;
249 # endif
250 #endif
251 } ieee_nan;
254 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
256 #elif LDBL_MANT_DIG == 53
258 union ieee854_long_double
260 long double d;
262 /* This is the IEEE 754 double-precision format. */
263 struct
265 #if __BYTE_ORDER == __BIG_ENDIAN
266 unsigned int negative:1;
267 unsigned int exponent:11;
268 /* Together these comprise the mantissa. */
269 unsigned int mantissa0:20;
270 unsigned int mantissa1:32;
271 #endif /* Big endian. */
272 #if __BYTE_ORDER == __LITTLE_ENDIAN
273 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
274 unsigned int mantissa0:20;
275 unsigned int exponent:11;
276 unsigned int negative:1;
277 unsigned int mantissa1:32;
278 # else
279 /* Together these comprise the mantissa. */
280 unsigned int mantissa1:32;
281 unsigned int mantissa0:20;
282 unsigned int exponent:11;
283 unsigned int negative:1;
284 # endif
285 #endif /* Little endian. */
286 } ieee;
288 /* This format makes it easier to see if a NaN is a signalling NaN. */
289 struct
291 #if __BYTE_ORDER == __BIG_ENDIAN
292 unsigned int negative:1;
293 unsigned int exponent:11;
294 unsigned int quiet_nan:1;
295 /* Together these comprise the mantissa. */
296 unsigned int mantissa0:19;
297 unsigned int mantissa1:32;
298 #else
299 # if __FLOAT_WORD_ORDER == __BIG_ENDIAN
300 unsigned int mantissa0:19;
301 unsigned int quiet_nan:1;
302 unsigned int exponent:11;
303 unsigned int negative:1;
304 unsigned int mantissa1:32;
305 # else
306 /* Together these comprise the mantissa. */
307 unsigned int mantissa1:32;
308 unsigned int mantissa0:19;
309 unsigned int quiet_nan:1;
310 unsigned int exponent:11;
311 unsigned int negative:1;
312 # endif
313 #endif
314 } ieee_nan;
317 #define IEEE854_LONG_DOUBLE_BIAS 0x3ff /* Added to exponent. */
319 #endif /* LDBL_MANT_DIG == 53 */
321 __END_DECLS
323 #endif /* ieee754.h */