61 be = bits + ((nbits - 1) >>
kshift);
67 *x++ = (*bits >> 16) &
ALL_ON;
69 }
while(++bits <= be);
124 (fpi, be, bits, kindp, mode, ndigits, decpt, rve)
FPI* fpi;
127 int *kindp, mode, ndigits, *decpt;
130 (
FPI* fpi,
int be,
ULong* bits,
int* kindp,
int mode,
int ndigits,
int* decpt,
char** rve)
167 int bbits, b2, b5, be0, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0, inex;
168 int j, j1, k, k0, k_check, kind, leftright, m2, m5, nbits;
169 int rdir, s2, s5, spec_case, try_quick;
171 Bigint *b, *b1, *delta, *mlo =
NULL, *mhi, *mhi1, *S;
172 double d, d2, ds, eps;
175 #ifndef MULTIPLE_THREADS 242 ds = (
dval(d) - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981;
292 if(mode < 0 || mode > 9)
308 i = (int)(nbits * .30103) + 3;
321 ilim = ilim1 = i = ndigits;
357 if(ilim >= 0 && ilim <=
Quick_max && try_quick && !rdir
358 #ifndef IMPRECISE_INEXACT
381 for(; j; j >>= 1, i++)
398 for(j = j1 >> 4; j; j >>= 1, i++)
410 if(k_check &&
dval(d) < 1. && ilim > 0)
454 *s++ = (char)(
'0' + (
int)L);
480 for(i = 1;; i++,
dval(d) *= 10.)
486 *s++ = (char)(
'0' + (
int)L);
525 if(ndigits < 0 && ilim <= 0)
528 if(ilim < 0 ||
dval(d) <= 5 * ds)
536 for(i = 1;; i++,
dval(d) *= 10.)
538 L = (int)(
dval(d) / ds);
540 #ifdef Check_FLT_ROUNDS 548 *s++ = (char)(
'0' + (
int)L);
606 if(be - i++ < fpi->
emin)
610 i = be - fpi->
emin + 1;
641 i = m2 < s2 ? m2 : s2;
657 if((j = b5 - m5) != 0)
684 if(bbits == 1 && be0 > fpi->
emin + 1)
701 if((i = ((s5 ? 32 -
hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0x1f) != 0)
708 if((i = ((s5 ? 32 -
hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0xf) != 0)
752 if(ilim <= 0 && mode > 2)
754 if(ilim < 0 ||
cmp(b, S =
multadd(S, 5, 0)) <= 0)
796 delta =
diff(S, mhi);
797 j1 = delta->
sign ? 1 :
cmp(b, delta);
800 if(j1 == 0 && !mode && !(bits[0] & 1) && !rdir)
810 if(b->
wds > 1 || b->
x[0])
826 if((j < 0) || ((j == 0) && !mode
832 if(rdir && (b->
wds > 1 || b->
x[0]))
839 while(
cmp(S, mhi) > 0)
866 if(((j1 > 0) || (j1 == 0 && dig & 1)) && (dig++ ==
'9'))
874 if(b->
wds > 1 || b->
x[0])
884 if(j1 > 0 && rdir != 2)
894 *s++ = (char)(dig + 1);
908 mlo = mhi =
multadd(mhi, 10, 0);
940 if((rdir == 2) || ((b->
wds <= 1) && !b->
x[0]))
950 if((j > 0) || ((j == 0) && (dig & 1)))
970 if(b->
wds > 1 || b->
x[0])
985 if(mlo && mlo != mhi)
Bigint * lshift(Bigint *b, int k)
double b2d(Bigint *a, int *e)
char * gdtoa(FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve)
Bigint * diff(Bigint *a, Bigint *b)
int quorem(Bigint *b, Bigint *S)
static Bigint * bitstob(ULong *bits, int nbits, int *bbits)
char * nrv_alloc(char *s, char **rve, int n)
void rshift(Bigint *b, int k)
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)