70 #ifdef Honor_FLT_ROUNDS 71 #define Rounding rounding 72 #undef Check_FLT_ROUNDS 73 #define Check_FLT_ROUNDS 75 #define Rounding Flt_Rounds 80 (d, mode, ndigits, decpt, sign, rve)
double d;
81 int mode, ndigits, *decpt, *sign;
84 (
double d,
int mode,
int ndigits,
int* decpt,
int* sign,
char** rve)
121 int bbits, b2, b5, be, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0, j, j1, k, k0, k_check,
122 leftright, m2, m5, s2, s5, spec_case, try_quick;
124 #ifndef Sudden_Underflow 128 Bigint *b, *b1, *delta, *mlo =
NULL, *mhi, *S;
131 #ifdef Honor_FLT_ROUNDS 135 int inexact, oldinexact;
138 #ifndef MULTIPLE_THREADS 159 #if defined(IEEE_Arith) + defined(VAX) 163 if(
word0(d) == 0x8000)
187 try_quick = oldinexact = get_inexact();
190 #ifdef Honor_FLT_ROUNDS 195 rounding = rounding == 2 ? 0 : 2;
208 #ifdef Sudden_Underflow 251 #ifndef Sudden_Underflow 258 i = bbits + be + (
Bias + (
P - 1) - 1);
259 x = i > 32 ?
word0(d) << (64 - i) |
word1(d) >> (i - 32) :
word1(d) << (32 - i);
262 i -= (
Bias + (
P - 1) - 1) + 1;
266 ds = (
dval(d2) - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981;
306 if(mode < 0 || mode > 9)
312 #ifdef Check_FLT_ROUNDS 343 ilim = ilim1 = i = ndigits;
359 #ifdef Honor_FLT_ROUNDS 360 if(mode > 1 && rounding != 1)
366 if(ilim >= 0 && ilim <=
Quick_max && try_quick)
386 for(; j; j >>= 1, i++)
398 else if((j1 = -k) != 0)
401 for(j = j1 >> 4; j; j >>= 1, i++)
412 if(k_check &&
dval(d) < 1. && ilim > 0)
450 *s++ =
'0' + (char)L;
472 for(i = 1;; i++,
dval(d) *= 10.)
481 *s++ =
'0' + (char)L;
518 if(ndigits < 0 && ilim <= 0)
521 if(ilim < 0 ||
dval(d) <= 5 * ds)
527 for(i = 1;; i++,
dval(d) *= 10.)
531 #ifdef Check_FLT_ROUNDS 539 *s++ =
'0' + (char)L;
549 #ifdef Honor_FLT_ROUNDS 590 #ifndef Sudden_Underflow 591 denorm ? be + (
Bias + (
P - 1) - 1 + 1) :
594 1 + 4 *
P - 3 - bbits + ((bbits + be - 1) & 3);
604 i = m2 < s2 ? m2 : s2;
620 if((j = b5 - m5) != 0)
639 if((mode < 2 || leftright)
666 if((i = ((s5 ? 32 -
hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0x1f) != 0)
671 if((i = ((s5 ? 32 -
hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0xf) != 0)
713 if(ilim <= 0 && (mode == 3 || mode == 5))
715 if(ilim < 0 ||
cmp(b, S =
multadd(S, 5, 0)) <= 0)
753 delta =
diff(S, mhi);
754 j1 = delta->
sign ? 1 :
cmp(b, delta);
757 if(j1 == 0 && mode != 1 && (!(
word1(d) & 1))
772 else if(!b->
x[0] && b->
wds <= 1)
781 if((j < 0) || ((j == 0) && (mode != 1)
783 && (!(
word1(d) & 1)))
787 if(!b->
x[0] && b->
wds <= 1)
794 #ifdef Honor_FLT_ROUNDS 812 if((j1 > 0) || ((j1 == 0) && (dig & 1) && (dig++ ==
'9')))
823 #ifdef Honor_FLT_ROUNDS 837 *s++ = (char)dig + 1;
840 #ifdef Honor_FLT_ROUNDS 851 mlo = mhi =
multadd(mhi, 10, 0);
867 if(!b->
x[0] && b->
wds <= 1)
885 #ifdef Honor_FLT_ROUNDS 896 if((j > 0) || ((j == 0) && (dig & 1)))
926 if(mlo && mlo != mhi)
943 else if(!oldinexact) clear_inexact();
Bigint * lshift(Bigint *b, int k)
Bigint * diff(Bigint *a, Bigint *b)
int quorem(Bigint *b, Bigint *S)
Bigint * d2b(double d, int *e, int *bits)
char * dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
char * nrv_alloc(char *s, char **rve, int n)
Bigint * multadd(Bigint *b, int m, int a)
Bigint * pow5mult(Bigint *b, int k)
int cmp(Bigint *a, Bigint *b)
Bigint * mult(Bigint *a, Bigint *b)