Lines Matching +full:max +full:- +full:adj
5 Copyright (C) 1998-2001 by Lucent Technologies
60 x = b->x;
61 xe = x + b->wds;
81 if (b->wds >= b->maxwds) {
82 b1 = Balloc(b->k+1);
87 b->x[b->wds++] = 1;
104 x = b->x;
105 xe = x + b->wds;
109 --*x;
117 y = *x - borrow;
133 x = b->x;
153 k = (n + ((1 << kshift) - 1)) >> kshift;
154 if (b->k < k) {
161 b->wds = k;
162 x = b->x;
167 x[-1] >>= ULbits - n;
186 bdif -= nb = fpi->nbits;
198 fpi->rounding ==
208 case 1: /* round down (toward -Infinity) */
213 k = bdif - 1;
219 if (b->x[0] & 2)
223 if (b->x[k>>kshift] & ((ULong)1 << (k & kmask)))
239 j = ULbits - j;
240 if (hi0bits(b->x[b->wds - 1]) != j) {
242 lostbits = b->x[0] & 1;
249 b = lshift(b, -bdif);
250 if (e < fpi->emin) {
251 k = fpi->emin - e;
252 e = fpi->emin;
253 if (k > nb || fpi->sudden_underflow) {
254 b->wds = inex = 0;
258 k1 = k - 1;
264 carry = b->x[k1>>kshift] & (1 << (k1 & kmask));
275 else if (e > fpi->emax) {
276 e = fpi->emax + 1;
281 b->wds = inex = 0;
306 return P - lo0bits(&L);
312 return P - 32 - lo0bits(&L);
332 U adj, rv; local
337 char *decimalpoint = localeconv_l(loc)->decimal_point;
344 s0 = localeconv_l(loc)->decimal_point;
361 nbits = fpi->nbits;
363 case '-':
404 sudden_underflow = fpi->sudden_underflow;
409 y = 10*y + c - '0';
411 z = 10*z + c - '0';
439 if (c -= '0') {
465 case '-':
474 L = c - '0';
477 L = 10*L + c - '0';
478 if (s - s1 > 8 || L > 19999)
486 e = -e;
503 --s;
514 *exp = fpi->emax + 1;
530 e1 = e -= nf;
532 switch(fpi->rounding & 3) {
534 rd = 2 - sign;
544 * decimal point, followed by nd-nd0 digits. The number we're
553 dval(&rv) = tens[k - 9] * dval(&rv) + z;
569 e1 -= e;
573 i = DBL_DIG - nd;
578 e2 = e - i;
579 e1 -= i;
586 dval(&adj) = dval(&rv);
587 word0(&adj) -= P*Exp_msk1;
588 /* adj = */ rounded_product(dval(&adj), tens[e2]);
589 if ((word0(&adj) & Exp_mask)
590 > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
592 word0(&adj) += P*Exp_msk1;
593 dval(&rv) = dval(&adj);
599 e1 -= e2;
603 else if (e >= -Ten_pmax) {
604 /* rv = */ rounded_quotient(dval(&rv), tens[-e]);
607 e1 -= e;
612 e1 += nd - k;
622 while(e1 >= (1 << (n_bigtens-1))) {
624 >> Exp_shift1) - Bias;
627 dval(&rv) *= bigtens[n_bigtens-1];
628 e1 -= 1 << (n_bigtens-1);
630 e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias;
639 e1 = -e1;
644 while(e1 >= (1 << (n_bigtens-1))) {
646 >> Exp_shift1) - Bias;
649 dval(&rv) *= tinytens[n_bigtens-1];
650 e1 -= 1 << (n_bigtens-1);
652 e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias;
670 if ((j = rvbits - nbits) > 0) {
676 e2 = rve + rvbits - nbits;
677 if (e2 > fpi->emax + 1)
679 rve1 = rve + rvbits - nbits;
680 if (e2 < (emin = fpi->emin)) {
682 j = rve - emin;
690 if (rvbits < -1) {
692 rvb->wds = 0;
693 rvb->x[0] = 0;
698 rvb->x[0] = rvb->wds = rvbits = 1;
701 rshift(rvb, -j);
708 /* Now the hard part -- adjusting rv to the correct value.*/
715 bd = Balloc(bd0->k);
717 bb = Balloc(rvb->k);
719 bbbits = rvbits - bb0;
728 bb2 = bb5 = -e;
734 bd2 -= bbe;
736 j = nbits + 1 - bbbits;
737 i = bbe + bbbits - nbits;
739 j += i - emin;
746 bb2 -= i;
747 bd2 -= i;
748 bs2 -= i;
756 bb2 -= bb0;
760 rshift(bb, -bb2);
770 if (delta->wds <= 1 && !delta->x[0])
772 dsign = delta->sign;
773 delta->sign = finished = 0;
787 i++, j -= ULbits) {
788 if (rvb->x[i] & ALL_ON)
791 if (j > 1 && lo0bits(rvb->x + i) < j - 1)
793 rve = rve1 - 1;
801 /* Error is less than half an ulp -- check for
817 /* exactly half-way between */
820 /*boundary case -- increment exponent*/
821 rvb->wds = 1;
822 rvb->x[0] = 1;
823 rve = emin + nbits - (rvbits = 1);
833 /* boundary case -- decrement exponent */
836 if (rvb->wds == 1 && rvb->x[0] == 1)
840 rve -= nbits;
846 if ((bbbits < nbits && !denorm) || !(rvb->x[0] & 1))
850 j = kmask & (ULbits - (rvbits & kmask));
851 if (hi0bits(rvb->x[rvb->wds - 1]) != j)
863 if ((dval(&adj) = ratio(delta, bs)) <= 2.) {
872 rvb->wds = 0;
877 adj0 = dval(&adj) = 1.;
880 adj0 = dval(&adj) *= 0.5;
885 if (dval(&adj) < 2147483647.) {
887 adj0 -= L;
901 inex = STRTOG_Inexact - inex;
904 dval(&adj) = L;
909 /* adj *= ulp(dval(&rv)); */
910 /* if (asub) rv -= adj; else rv += adj; */
913 rvb = lshift(rvb, j = nbits - rvbits);
914 rve -= j;
917 ab = d2b(dval(&adj), &abe, &abits);
919 rshift(ab, -abe);
924 /* rv -= adj; */
925 j = hi0bits(rvb->x[rvb->wds-1]);
927 k = rvb0->wds - 1;
930 else if (rvb->wds <= k
931 || hi0bits( rvb->x[k]) >
932 hi0bits(rvb0->x[k])) {
935 --rvbits;
940 --rve;
941 --rve1;
948 k = rvb->wds - 1;
949 if (k >= rvb0->wds
950 || hi0bits(rvb->x[k]) < hi0bits(rvb0->x[k])) {
971 tol = dval(&adj) * 5e-16; /* > max rel error */
972 dval(&adj) = adj0 - .5;
973 if (dval(&adj) < -tol) {
979 else if (dval(&adj) > tol && adj0 < 1. - tol) {
990 if (!denorm && (j = nbits - rvbits)) {
994 rshift(rvb, -j);
995 rve -= j;
1003 if (rve > fpi->emax) {
1004 switch(fpi->rounding & 3) {
1019 *exp = fpi->emax;
1021 be = b + ((fpi->nbits + 31) >> 5);
1023 *b++ = -1;
1024 if ((j = fpi->nbits & 0x1f))
1025 *--be >>= (32 - j);
1028 rvb->wds = 0;
1034 *exp = fpi->emax + 1;
1039 rvb->wds = 0;
1047 (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero);