46 #define Avoid_Underflow 50 static CONST double tinytens[] = {1e-16, 1e-32, 1e-64, 1e-128, 9007199254740992.e-256};
54 #ifdef Honor_FLT_ROUNDS 55 #define Rounding rounding 56 #undef Check_FLT_ROUNDS 57 #define Check_FLT_ROUNDS 59 #define Rounding Flt_Rounds 64 (s00, se)
CONST char* s00;
70 #ifdef Avoid_Underflow 73 int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign, e, e1, esign, i, j, k, nd, nd0, nf,
75 CONST char *s, *s0, *s1;
76 double aadj, aadj1, adj, rv, rv0;
81 int inexact, oldinexact;
83 #ifdef Honor_FLT_ROUNDS 87 sign = nz0 = nz = decpt = 0;
120 static FPI fpi = {53, 1 - 1023 - 53 + 1, 2046 - 1023 - 53 + 1, 1,
SI};
128 #if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD) 157 ULtod(((
U*)&rv)->L, bits, exp, i);
176 for(nd = nf = 0; (c = *s) >=
'0' && c <=
'9'; nd++, s++)
180 y = 10 * y + (unsigned)c -
'0';
184 z = 10 * z + (unsigned)c -
'0';
198 for(; c ==
'0'; c = *++s)
202 if(c >
'0' && c <=
'9')
211 for(; c >=
'0' && c <=
'9'; c = *++s)
218 for(i = 1; i < nz; i++)
231 y = 10 * y + (unsigned)c;
235 z = 10 * z + (unsigned)c;
243 if(c ==
'e' || c ==
'E')
245 if(!nd && !nz && !nz0)
258 if(c >=
'0' && c <=
'9')
264 if(c >
'0' && c <=
'9')
268 while((c = *++s) >=
'0' && c <=
'9')
270 L = 10 * L + c -
'0';
272 if(s - s1 > 8 || L > 19999)
306 {52, 1 - 1023 - 53 + 1, 2046 - 1023 - 53 + 1, 1,
SI};
315 if(!
match(&s,
"inity"))
317 word0(rv) = 0x7ff00000;
330 word0(rv) = 0x7ff00000 | bits[1];
336 word0(rv) = NAN_WORD0;
337 word1(rv) = NAN_WORD1;
368 oldinexact = get_inexact();
392 #ifdef Honor_FLT_ROUNDS 410 #ifdef Honor_FLT_ROUNDS 438 #ifndef Inaccurate_Divide 441 #ifdef Honor_FLT_ROUNDS 461 oldinexact = get_inexact();
464 #ifdef Avoid_Underflow 467 #ifdef Honor_FLT_ROUNDS 472 rounding = rounding == 2 ? 0 : 2;
474 else if(rounding != 2)
486 if((i = e1 & 15) != 0)
500 #ifdef Honor_FLT_ROUNDS 532 for(j = 0; e1 > 1; j++, e1 >>= 1)
562 if((i = e1 & 15) != 0)
568 if(e1 >= 1 << n_bigtens)
572 #ifdef Avoid_Underflow 577 for(j = 0; e1 > 0; j++, e1 >>= 1)
596 word0(rv) &= 0xffffffff << (j - 32);
601 word1(rv) &= 0xffffffff << j;
605 for(j = 0; e1 > 1; j++, e1 >>= 1)
633 #ifndef Avoid_Underflow 648 bd0 =
s2b(s0, nd0, nd, y);
654 bb =
d2b(
dval(rv), &bbe, &bbbits);
676 #ifdef Honor_FLT_ROUNDS 682 #ifdef Avoid_Underflow 694 #ifdef Sudden_Underflow 696 j = 1 + 4 *
P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
715 #ifdef Avoid_Underflow 718 i = bb2 < bd2 ? bb2 : bd2;
752 delta =
diff(bb, bd);
756 #ifdef Honor_FLT_ROUNDS 762 if(!delta->x[0] && delta->wds <= 1)
784 #ifdef Avoid_Underflow 791 if(
cmp(delta, bs) <= 0)
798 #ifdef Avoid_Underflow 804 #ifdef Sudden_Underflow 818 adj =
ratio(delta, bs);
823 if(adj <= 0x7ffffffe)
829 if(!((rounding >> 1) ^ dsign))
836 #ifdef Avoid_Underflow 842 #ifdef Sudden_Underflow 880 #ifdef Avoid_Underflow
889 if(!delta->x[0] && delta->wds <= 1)
896 if(!delta->x[0] && delta->wds <= 1)
905 if(
cmp(delta, bs) > 0)
918 #ifdef Avoid_Underflow
920 ? (0xffffffff & (0xffffffff << (2 *
P + 1 - (y >>
Exp_shift))))
932 #ifdef Avoid_Underflow 942 #ifdef Sudden_Underflow 947 #ifdef Avoid_Underflow 956 #ifdef Avoid_Underflow 976 word1(rv) = 0xffffffff;
997 #ifndef Sudden_Underflow 1004 #ifdef Avoid_Underflow 1010 if((aadj =
ratio(delta, bs)) <= 2.)
1018 #ifndef Sudden_Underflow 1046 aadj1 = dsign ? aadj : -aadj;
1047 #ifdef Check_FLT_ROUNDS 1091 #ifdef Avoid_Underflow 1094 if(aadj <= 0x7fffffff)
1102 aadj1 = dsign ? aadj : -aadj;
1109 #ifdef Sudden_Underflow 1148 if(y <= (
P - 1) *
Exp_msk1 && aadj > 1.)
1150 aadj1 = (double)(
int)(aadj + 0.5);
1163 #ifdef Avoid_Underflow 1175 if(aadj < .4999999 || aadj > .5000001)
1185 #ifdef Avoid_Underflow 1205 else if(!oldinexact)
1210 #ifdef Avoid_Underflow 1260 *se = (
char*)(uintptr_t)s;
1262 return sign ? -
dval(rv) :
dval(rv);
int hexnan(CONST char **sp, FPI *fpi, ULong *x0)
Bigint * lshift(Bigint *b, int k)
Bigint * diff(Bigint *a, Bigint *b)
struct lconv * localeconv(void)
int gethex(CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
Bigint * d2b(double d, int *e, int *bits)
#define rounded_product(a, b)
#define rounded_quotient(a, b)
double ratio(Bigint *a, Bigint *b)
void copybits(ULong *c, int n, Bigint *b)
Bigint * s2b(CONST char *s, int nd0, int nd, ULong y9)
double strtod(CONST char *s00, char **se)
void ULtod(ULong *L, const ULong *bits, Long exp, int k)
Bigint * pow5mult(Bigint *b, int k)
int cmp(Bigint *a, Bigint *b)
Bigint * mult(Bigint *a, Bigint *b)