Fix copy&paste error.
[glibc/history.git] / sysdeps / ia64 / ieee754.h
blobf5a71f5b924864965a755c6bf5d9c1c73076675f
1 /* Copyright (C) 2000 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 empty0:32;
139 unsigned int negative:1;
140 unsigned int exponent:15;
141 unsigned int empty1:16;
142 unsigned int mantissa0:32;
143 unsigned int mantissa1:32;
144 #endif
145 #if __BYTE_ORDER == __LITTLE_ENDIAN
146 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
147 unsigned int empty0:32;
148 unsigned int exponent:15;
149 unsigned int negative:1;
150 unsigned int empty1:16;
151 unsigned int mantissa0:32;
152 unsigned int mantissa1:32;
153 # else
154 unsigned int mantissa1:32;
155 unsigned int mantissa0:32;
156 unsigned int exponent:15;
157 unsigned int negative:1;
158 unsigned int empty1:16;
159 unsigned int empty0:32;
160 # endif
161 #endif
162 } ieee;
164 /* This is for NaNs in the IEEE 854 double-extended-precision format. */
165 struct
167 #if __BYTE_ORDER == __BIG_ENDIAN
168 unsigned int empty0:32;
169 unsigned int negative:1;
170 unsigned int exponent:15;
171 unsigned int empty1:16;
172 unsigned int one:1;
173 unsigned int quiet_nan:1;
174 unsigned int mantissa0:30;
175 unsigned int mantissa1:32;
176 #endif
177 #if __BYTE_ORDER == __LITTLE_ENDIAN
178 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
179 unsigned int empty0:32;
180 unsigned int exponent:15;
181 unsigned int negative:1;
182 unsigned int empty1:16;
183 unsigned int mantissa0:30;
184 unsigned int quiet_nan:1;
185 unsigned int one:1;
186 unsigned int mantissa1:32;
187 # else
188 unsigned int mantissa1:32;
189 unsigned int mantissa0:30;
190 unsigned int quiet_nan:1;
191 unsigned int one:1;
192 unsigned int exponent:15;
193 unsigned int negative:1;
194 unsigned int empty1:16;
195 unsigned int empty0:32;
196 # endif
197 #endif
198 } ieee_nan;
201 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
203 __END_DECLS
205 #endif /* ieee754.h */