1 /****************************************************************
3 * The author of this software is David M. Gay.
5 * Copyright (c) 1991 by AT&T.
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose without fee is hereby granted, provided that this entire notice
9 * is included in all copies of any software which is or includes a copy
10 * or modification of this software and in all copies of the supporting
11 * documentation for such software.
13 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
14 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
15 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
16 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
18 ***************************************************************/
20 /* Please send bug reports to
22 AT&T Bell Laboratories, Room 2C-463
24 Murray Hill, NJ 07974-2070
26 dmg@research.att.com or research!dmg
29 /* This header file is a modification of mprec.h that only contains floating
37 #include <sys/config.h>
38 #include <sys/cdefs.h>
40 #ifdef __IEEE_LITTLE_ENDIAN
44 #ifdef __IEEE_BIG_ENDIAN
52 #ifdef Unsigned_Shifts
53 #define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000;
55 #define Sign_Extend(a,b) /*no-op*/
58 #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
59 Exactly one of IEEE_8087
, IEEE_MC68k
, VAX
, or IBM should be defined
.
62 #ifdef _WANT_IO_LONG_DOUBLE
63 /* If we are going to examine or modify specific bits in a long double using
64 the lword0 or lwordx macros, then we must wrap the long double inside
65 a union. This is necessary to avoid undefined behavior according to
69 #if LDBL_MANT_DIG == 24
76 #elif LDBL_MANT_DIG == 53
84 #elif LDBL_MANT_DIG == 64
92 #elif LDBL_MANT_DIG > 64
102 #endif /* LDBL_MANT_DIG */
103 #else /* !IEEE_8087 */
104 #if LDBL_MANT_DIG == 24
111 #elif LDBL_MANT_DIG == 53
119 #elif LDBL_MANT_DIG == 64
127 #elif LDBL_MANT_DIG > 64
137 #endif /* LDBL_MANT_DIG */
138 #endif /* !IEEE_8087 */
139 #endif /* _WANT_IO_LONG_DOUBLE */
141 /* If we are going to examine or modify specific bits in a double using
142 the word0 and/or word1 macros, then we must wrap the double inside
143 a union. This is necessary to avoid undefined behavior according to
152 #define word0(x) (x.i[1])
153 #define word1(x) (x.i[0])
155 #define word0(x) (x.i[0])
156 #define word1(x) (x.i[1])
159 /* #define P DBL_MANT_DIG */
160 /* Ten_pmax = floor(P*log(2)/log(5)) */
161 /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
162 /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
163 /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
165 #if defined(IEEE_8087) + defined(IEEE_MC68k)
166 #if defined (_DOUBLE_IS_32BITS)
168 #define Exp_shift1 23
169 #define Exp_msk1 ((__uint32_t)0x00800000L)
170 #define Exp_msk11 ((__uint32_t)0x00800000L)
171 #define Exp_mask ((__uint32_t)0x7f800000L)
176 #define Exp_1 ((__uint32_t)0x3f800000L)
177 #define Exp_11 ((__uint32_t)0x3f800000L)
179 #define Frac_mask ((__uint32_t)0x007fffffL)
180 #define Frac_mask1 ((__uint32_t)0x007fffffL)
182 #define Sign_bit ((__uint32_t)0x80000000L)
185 #define Bndry_mask ((__uint32_t)0x007fffffL)
186 #define Bndry_mask1 ((__uint32_t)0x007fffffL)
188 #define Sign_bit ((__uint32_t)0x80000000L)
194 #define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
198 #define word0(x) (x.i[0])
203 #define Exp_shift1 20
204 #define Exp_msk1 ((__uint32_t)0x100000L)
205 #define Exp_msk11 ((__uint32_t)0x100000L)
206 #define Exp_mask ((__uint32_t)0x7ff00000L)
211 #define Exp_1 ((__uint32_t)0x3ff00000L)
212 #define Exp_11 ((__uint32_t)0x3ff00000L)
214 #define Frac_mask ((__uint32_t)0xfffffL)
215 #define Frac_mask1 ((__uint32_t)0xfffffL)
218 #define Bndry_mask ((__uint32_t)0xfffffL)
219 #define Bndry_mask1 ((__uint32_t)0xfffffL)
221 #define Sign_bit ((__uint32_t)0x80000000L)
227 #define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */
231 #undef Sudden_Underflow
232 #define Sudden_Underflow
235 #define Exp_shift1 24
236 #define Exp_msk1 ((__uint32_t)0x1000000L)
237 #define Exp_msk11 ((__uint32_t)0x1000000L)
238 #define Exp_mask ((__uint32_t)0x7f000000L)
241 #define Exp_1 ((__uint32_t)0x41000000L)
242 #define Exp_11 ((__uint32_t)0x41000000L)
243 #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
244 #define Frac_mask ((__uint32_t)0xffffffL)
245 #define Frac_mask1 ((__uint32_t)0xffffffL)
248 #define Bndry_mask ((__uint32_t)0xefffffL)
249 #define Bndry_mask1 ((__uint32_t)0xffffffL)
251 #define Sign_bit ((__uint32_t)0x80000000L)
253 #define Tiny0 ((__uint32_t)0x100000L)
260 #define Exp_msk1 0x80
261 #define Exp_msk11 ((__uint32_t)0x800000L)
262 #define Exp_mask ((__uint32_t)0x7f80L)
265 #define Exp_1 ((__uint32_t)0x40800000L)
266 #define Exp_11 ((__uint32_t)0x4080L)
268 #define Frac_mask ((__uint32_t)0x7fffffL)
269 #define Frac_mask1 ((__uint32_t)0xffff007fL)
272 #define Bndry_mask ((__uint32_t)0xffff007fL)
273 #define Bndry_mask1 ((__uint32_t)0xffff007fL)
274 #define LSB ((__uint32_t)0x10000L)
275 #define Sign_bit ((__uint32_t)0x8000L)