34 #include <sys/config.h>
35 #include <sys/types.h>
37 #ifdef __IEEE_LITTLE_ENDIAN
41 #ifdef __IEEE_BIG_ENDIAN
51 #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
54 #ifdef Unsigned_Shifts
55 #define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000;
57 #define Sign_Extend(a,b)
60 #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
61 Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
75 #define word0(x) (x.i[1])
76 #define word1(x) (x.i[0])
78 #define word0(x) (x.i[0])
79 #define word1(x) (x.i[1])
86 #if defined (__IEEE_BYTES_LITTLE_ENDIAN) + defined (IEEE_8087) + defined (VAX)
87 #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
88 ((unsigned short *)a)[0] = (unsigned short)c, a++)
90 #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
91 ((unsigned short *)a)[1] = (unsigned short)c, a++)
100 #if defined(IEEE_8087) + defined(IEEE_MC68k)
101 #if defined (_DOUBLE_IS_32BITS)
103 #define Exp_shift1 23
104 #define Exp_msk1 ((__uint32_t)0x00800000L)
105 #define Exp_msk11 ((__uint32_t)0x00800000L)
106 #define Exp_mask ((__uint32_t)0x7f800000L)
113 #define Exp_1 ((__uint32_t)0x3f800000L)
114 #define Exp_11 ((__uint32_t)0x3f800000L)
116 #define Frac_mask ((__uint32_t)0x007fffffL)
117 #define Frac_mask1 ((__uint32_t)0x007fffffL)
119 #define Sign_bit ((__uint32_t)0x80000000L)
122 #define Bndry_mask ((__uint32_t)0x007fffffL)
123 #define Bndry_mask1 ((__uint32_t)0x007fffffL)
125 #define Sign_bit ((__uint32_t)0x80000000L)
131 #define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
135 #define word0(x) (x.i[0])
140 #define Exp_shift1 20
141 #define Exp_msk1 ((__uint32_t)0x100000L)
142 #define Exp_msk11 ((__uint32_t)0x100000L)
143 #define Exp_mask ((__uint32_t)0x7ff00000L)
148 #define Exp_1 ((__uint32_t)0x3ff00000L)
149 #define Exp_11 ((__uint32_t)0x3ff00000L)
151 #define Frac_mask ((__uint32_t)0xfffffL)
152 #define Frac_mask1 ((__uint32_t)0xfffffL)
155 #define Bndry_mask ((__uint32_t)0xfffffL)
156 #define Bndry_mask1 ((__uint32_t)0xfffffL)
158 #define Sign_bit ((__uint32_t)0x80000000L)
164 #define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L))
168 #undef Sudden_Underflow
169 #define Sudden_Underflow
172 #define Exp_shift1 24
173 #define Exp_msk1 ((__uint32_t)0x1000000L)
174 #define Exp_msk11 ((__uint32_t)0x1000000L)
175 #define Exp_mask ((__uint32_t)0x7f000000L)
178 #define Exp_1 ((__uint32_t)0x41000000L)
179 #define Exp_11 ((__uint32_t)0x41000000L)
181 #define Frac_mask ((__uint32_t)0xffffffL)
182 #define Frac_mask1 ((__uint32_t)0xffffffL)
185 #define Bndry_mask ((__uint32_t)0xefffffL)
186 #define Bndry_mask1 ((__uint32_t)0xffffffL)
188 #define Sign_bit ((__uint32_t)0x80000000L)
190 #define Tiny0 ((__uint32_t)0x100000L)
197 #define Exp_msk1 0x80
198 #define Exp_msk11 ((__uint32_t)0x800000L)
199 #define Exp_mask ((__uint32_t)0x7f80L)
202 #define Exp_1 ((__uint32_t)0x40800000L)
203 #define Exp_11 ((__uint32_t)0x4080L)
205 #define Frac_mask ((__uint32_t)0x7fffffL)
206 #define Frac_mask1 ((__uint32_t)0xffff007fL)
209 #define Bndry_mask ((__uint32_t)0xffff007fL)
210 #define Bndry_mask1 ((__uint32_t)0xffff007fL)
211 #define LSB ((__uint32_t)0x10000L)
212 #define Sign_bit ((__uint32_t)0x8000L)
226 #define rounded_product(a,b) a = rnd_prod(a, b)
227 #define rounded_quotient(a,b) a = rnd_quot(a, b)
229 extern double rnd_prod(), rnd_quot();
231 extern double rnd_prod(
double,
double), rnd_quot(
double,
double);
234 #define rounded_product(a,b) a *= b
235 #define rounded_quotient(a,b) a /= b
238 #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
239 #define Big1 ((__uint32_t)0xffffffffL)
255 extern "C" double strtod(
const char *s00,
char **se);
256 extern "C" char *dtoa(
double d,
int mode,
int ndigits,
257 int *decpt,
int *sign,
char **rve);
261 typedef struct _Bigint _Bigint;
263 #if (defined (_SMALL_PRINTF) || defined(SMALL_SCANF) )
272 #define small_Balloc _small_Balloc
273 #define small_Bfree _small_Bfree
274 #define small_multadd _small_multadd
275 #define small_s2b _small_s2b
276 #define small_lo0bits _small_lo0bits
277 #define small_hi0bits _small_hi0bits
278 #define small_i2b _small_i2b
279 #define small_mult _small_multiply
280 #define small_pow5mult _small_pow5mult
281 #define small_lshift _small_lshift
282 #define small_cmp __small_mcmp
283 #define small_diff __small_mdiff
284 #define small_ulp _small_ulp
285 #define small_b2d _small_b2d
286 #define small_d2b _small_d2b
287 #define small_ratio _small_ratio
289 #define small_tens __small_mprec_tens
290 #define small_bigtens __small_mprec_bigtens
291 #define small_tinytens __small_mprec_tinytens
294 double _EXFUN(small_ulp,(
double x));
295 double _EXFUN(small_b2d,(_Bigint *a ,
int *e));
296 _Bigint * _EXFUN(small_multadd,(
struct _reent *p, _Bigint *,
int,
int,_Bigint tab[]));
297 _Bigint * _EXFUN(small_s2b,(
struct _reent *,
const char*,
int,
int, __ULong,_Bigint tab[]));
298 _Bigint * _EXFUN(small_i2b,(
struct _reent *,
int,_Bigint tab[]));
299 _Bigint * _EXFUN(small_mult, (
struct _reent *, _Bigint *, _Bigint *,_Bigint tab[]));
300 _Bigint * _EXFUN(small_pow5mult, (
struct _reent *, _Bigint *,
int k,_Bigint tab[]));
301 int _EXFUN(small_hi0bits,(__ULong));
302 int _EXFUN(small_lo0bits,(__ULong *));
303 _Bigint * _EXFUN(small_d2b,(
struct _reent *p,
double d,
int *e,
int *bits,_Bigint tab[]));
304 _Bigint * _EXFUN(small_lshift,(
struct _reent *p, _Bigint *b,
int k,_Bigint tab[]));
305 _Bigint * _EXFUN(small_diff,(
struct _reent *p, _Bigint *a, _Bigint *b,_Bigint tab[]));
306 int _EXFUN(small_cmp,(_Bigint *a, _Bigint *b));
308 double _EXFUN(small_ratio,(_Bigint *a, _Bigint *b));
309 #define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(__Long) + 2*sizeof(int))
311 #if defined(_DOUBLE_IS_32BITS) && defined(__v800)
317 extern _CONST
double small_tinytens[];
318 extern _CONST
double small_bigtens[];
319 extern _CONST
double small_tens[];
322 double _EXFUN(_small_mprec_log10,(
int));
325 #else // NO SMALL_LIB
329 #define Balloc _Balloc
331 #define multadd _multadd
333 #define lo0bits _lo0bits
334 #define hi0bits _hi0bits
336 #define mult _multiply
337 #define pow5mult _pow5mult
338 #define lshift _lshift
346 #define tens __mprec_tens
347 #define bigtens __mprec_bigtens
348 #define tinytens __mprec_tinytens
351 double _EXFUN(ulp,(
double x));
352 double _EXFUN(b2d,(_Bigint *a ,
int *e));
353 _Bigint * _EXFUN(Balloc,(
struct _reent *p,
int k));
354 void _EXFUN(Bfree,(
struct _reent *p, _Bigint *v));
355 _Bigint * _EXFUN(multadd,(
struct _reent *p, _Bigint *,
int,
int));
356 _Bigint * _EXFUN(s2b,(
struct _reent *,
const char*,
int,
int, __ULong));
357 _Bigint * _EXFUN(i2b,(
struct _reent *,
int));
358 _Bigint * _EXFUN(mult, (
struct _reent *, _Bigint *, _Bigint *));
359 _Bigint * _EXFUN(pow5mult, (
struct _reent *, _Bigint *,
int k));
360 int _EXFUN(hi0bits,(__ULong));
361 int _EXFUN(lo0bits,(__ULong *));
362 _Bigint * _EXFUN(d2b,(
struct _reent *p,
double d,
int *e,
int *bits));
363 _Bigint * _EXFUN(lshift,(
struct _reent *p, _Bigint *b,
int k));
364 _Bigint * _EXFUN(diff,(
struct _reent *p, _Bigint *a, _Bigint *b));
365 int _EXFUN(cmp,(_Bigint *a, _Bigint *b));
367 double _EXFUN(ratio,(_Bigint *a, _Bigint *b));
368 #define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(__Long) + 2*sizeof(int))
370 #if defined(_DOUBLE_IS_32BITS) && defined(__v800)
376 extern _CONST
double tinytens[];
377 extern _CONST
double bigtens[];
378 extern _CONST
double tens[];
381 double _EXFUN(_mprec_log10,(
int));