2.9
[glibc/nacl-glibc.git] / sysdeps / ieee754 / ldbl-128ibm / ieee754.h
blob94a2091c84443a67ce9095d5e4ee819b051938e4
1 /* Copyright (C) 1992, 1995, 1996, 1999, 2004, 2006
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _IEEE754_H
22 #define _IEEE754_H 1
23 #include <features.h>
25 #include <endian.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 /* Together these comprise the mantissa. */
85 unsigned int mantissa1:32;
86 unsigned int mantissa0:20;
87 unsigned int exponent:11;
88 unsigned int negative:1;
89 #endif /* Little endian. */
90 } ieee;
92 /* This format makes it easier to see if a NaN is a signalling NaN. */
93 struct
95 #if __BYTE_ORDER == __BIG_ENDIAN
96 unsigned int negative:1;
97 unsigned int exponent:11;
98 unsigned int quiet_nan:1;
99 /* Together these comprise the mantissa. */
100 unsigned int mantissa0:19;
101 unsigned int mantissa1:32;
102 #else
103 /* Together these comprise the mantissa. */
104 unsigned int mantissa1:32;
105 unsigned int mantissa0:19;
106 unsigned int quiet_nan:1;
107 unsigned int exponent:11;
108 unsigned int negative:1;
109 #endif
110 } ieee_nan;
113 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
116 union ieee854_long_double
118 long double d;
120 /* This is the IEEE 854 quad-precision format. */
121 struct
123 #if __BYTE_ORDER == __BIG_ENDIAN
124 unsigned int negative:1;
125 unsigned int exponent:15;
126 /* Together these comprise the mantissa. */
127 unsigned int mantissa0:16;
128 unsigned int mantissa1:32;
129 unsigned int mantissa2:32;
130 unsigned int mantissa3:32;
131 #endif /* Big endian. */
132 #if __BYTE_ORDER == __LITTLE_ENDIAN
133 /* Together these comprise the mantissa. */
134 unsigned int mantissa3:32;
135 unsigned int mantissa2:32;
136 unsigned int mantissa1:32;
137 unsigned int mantissa0:16;
138 unsigned int exponent:15;
139 unsigned int negative:1;
140 #endif /* Little endian. */
141 } ieee;
143 /* This format makes it easier to see if a NaN is a signalling NaN. */
144 struct
146 #if __BYTE_ORDER == __BIG_ENDIAN
147 unsigned int negative:1;
148 unsigned int exponent:15;
149 unsigned int quiet_nan:1;
150 /* Together these comprise the mantissa. */
151 unsigned int mantissa0:15;
152 unsigned int mantissa1:32;
153 unsigned int mantissa2:32;
154 unsigned int mantissa3:32;
155 #else
156 /* Together these comprise the mantissa. */
157 unsigned int mantissa3:32;
158 unsigned int mantissa2:32;
159 unsigned int mantissa1:32;
160 unsigned int mantissa0:15;
161 unsigned int quiet_nan:1;
162 unsigned int exponent:15;
163 unsigned int negative:1;
164 #endif
165 } ieee_nan;
168 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff /* Added to exponent. */
171 /* IBM extended format for long double.
173 Each long double is made up of two IEEE doubles. The value of the
174 long double is the sum of the values of the two parts. The most
175 significant part is required to be the value of the long double
176 rounded to the nearest double, as specified by IEEE. For Inf
177 values, the least significant part is required to be one of +0.0 or
178 -0.0. No other requirements are made; so, for example, 1.0 may be
179 represented as (1.0, +0.0) or (1.0, -0.0), and the low part of a
180 NaN is don't-care. */
182 union ibm_extended_long_double
184 long double d;
185 double dd[2];
187 /* This is the IBM extended format long double. */
188 struct
189 { /* Big endian. There is no other. */
191 unsigned int negative:1;
192 unsigned int exponent:11;
193 /* Together Mantissa0-3 comprise the mantissa. */
194 unsigned int mantissa0:20;
195 unsigned int mantissa1:32;
197 unsigned int negative2:1;
198 unsigned int exponent2:11;
199 /* There is an implied 1 here? */
200 /* Together these comprise the mantissa. */
201 unsigned int mantissa2:20;
202 unsigned int mantissa3:32;
203 } ieee;
206 #define IBM_EXTENDED_LONG_DOUBLE_BIAS 0x3ff /* Added to exponent. */
208 __END_DECLS
210 #endif /* ieee754.h */