Lines Matching defs:digits

82 #define MPD_NEW_STATIC(name, flags, exp, digits, len) \
84 mpd_t name = {flags|MPD_STATIC|MPD_STATIC_DATA, exp, digits, \
87 #define MPD_NEW_CONST(name, flags, exp, digits, len, alloc, initval) \
89 mpd_t name = {flags|MPD_STATIC|MPD_CONST_DATA, exp, digits, \
94 a->exp, a->digits, a->len, a->alloc, a->data}
204 return (dec->exp + dec->digits) - 1;
246 /* Coefficient size needed to store 'digits' */
248 mpd_digits_to_size(mpd_ssize_t digits)
252 _mpd_idiv_word(&q, &r, digits, MPD_RDIGITS);
256 /* Number of digits in the exponent. Not defined for MPD_SSIZE_MIN. */
615 /* Set digits. Assumption: result->len is initialized and > 0. */
620 result->digits = wdigits + (result->len-1) * MPD_RDIGITS;
780 result->digits = 1;
799 result->digits = ctx->prec;
811 * Cut off the most significant digits so that the rest fits in ctx->prec.
820 if (result->len > 0 && result->digits > ctx->prec) {
840 * Cut off the most significant digits of a NaN payload so that the rest
851 if (result->len > 0 && result->digits > prec) {
854 result->len = result->digits = 0;
871 result->len = result->digits = 0;
878 * Get n most significant digits from a decimal, where 0 < n <= MPD_UINT_DIGITS.
893 _mpd_div_word(&tmp, &r, dec->digits, MPD_RDIGITS);
894 r = (r == 0) ? MPD_RDIGITS : r; /* digits in the most significant word */
999 /* All digits of a word are nines */
1013 /* All digits of the coefficient are nines */
1082 result->exp = result->digits = result->len = 0;
1092 result->exp = result->digits = result->len = 0;
1352 if (a->digits+a->exp > MPD_RDIGITS+1) {
1362 /* At this point a->digits+a->exp <= MPD_RDIGITS+1,
1740 /* We have a number with exactly ctx->prec digits. The increment
1742 * that case, the result is a power of ten with prec+1 digits.
1757 if (dec->digits > ctx->prec) {
1760 dec->digits = ctx->prec;
1805 if (dec->digits > ctx->prec) {
1871 /* At this point adjexp=exp+digits-1 <= emax and exp > etop=emax-prec+1:
1873 * (2) digits+shift = exp+digits-1 - emax + prec <= prec */
1901 /* At this point adjexp=exp+digits-1 < emin and exp < etiny=emin-prec+1:
1903 * (2) digits-shift = exp+digits-1 - emin + prec < prec */
1919 * (1) adjexp=exp+digits-1 < emin
1920 * (2) digits < emin-exp+1 <= prec */
1950 if (dec->digits > ctx->prec) {
1951 shift = dec->digits - ctx->prec;
1988 dest->digits = src->digits;
2010 result->digits = a->digits;
2029 result->digits = a->digits;
2049 result->digits = a->digits;
2068 result->digits = a->digits;
2202 /* Cannot wrap: a->exp + a->digits = b->exp + b->digits, so
2203 * a->exp - b->exp = b->digits - a->digits. */
2215 * so a->digits == b->digits, therefore a->len == b->len.
2513 size = mpd_digits_to_size(a->digits+n);
2522 result->digits = a->digits+n;
2528 /* Determine the rounding indicator if all digits of the coefficient are shifted
2536 /* special treatment for the most significant digit if shift == digits */
2569 if (n >= a->digits) {
2570 rnd = _mpd_get_rnd(a->data, a->len, (n==a->digits));
2574 result->digits = a->digits-n;
2575 size = mpd_digits_to_size(result->digits);
2605 if (n >= result->digits) {
2606 rnd = _mpd_get_rnd(result->data, result->len, (n==result->digits));
2611 result->digits -= n;
2612 size = mpd_digits_to_size(result->digits);
2644 if (n >= a->digits) {
2645 rnd = _mpd_get_rnd(a->data, a->len, (n==a->digits));
2649 result->digits = a->digits-n;
2650 size = mpd_digits_to_size(result->digits);
2692 if (b->digits > a->digits) {
2735 /* scan the rest of y for digits > 1 */
2743 /* scan the rest of big for digits > 1 */
2805 mpd_ssize_t i, digits, len;
2814 digits = (a->digits < ctx->prec) ? ctx->prec : a->digits;
2815 _mpd_idiv_word(&q, &r, digits, MPD_RDIGITS);
2883 if (b->digits > a->digits) {
2925 /* scan for digits > 1 and copy the rest of y */
2935 /* scan for digits > 1 and copy the rest of big */
2961 * Rotate the coefficient of 'a' by 'b' digits. 'b' must be an integer with
3007 if (a->digits > ctx->prec) {
3106 * Shift the coefficient by n digits, positive n is a left shift. In the case
3202 if (b->digits > a->digits) {
3244 /* scan for digits > 1 and copy the rest of y */
3254 /* scan for digits > 1 and copy the rest of big */
3357 exp += (big->digits > ctx->prec) ? 0 : big->digits-ctx->prec-1;
3371 * ----------X1 -> tiny-digits
3382 * ----------X1 -> tiny-digits
3393 tiny.digits = 1;
3791 shift = (b->digits - a->digits) + ctx->prec + 1;
3906 * We need an upper bound for the number of digits of a_coeff / b_coeff
3912 * The largest amount of digits is generated if b_coeff' is a power of 2 or
3920 * a->digits + b->digits * 4;
3925 workctx.prec = a->digits + b->digits * 4;
3972 /* positive and less than b->digits - a->digits */
3995 * (1) 0 <= a->exp + a->digits - b->exp - b->digits <= prec
3996 * (2) a->exp - b->exp >= b->digits - a->digits
3997 * (3) a->exp - b->exp <= prec + b->digits - a->digits
4002 /* by (3), after the shift a->digits <= prec + b->digits */
4010 /* by (2), after the shift b->digits <= a->digits */
4067 if (q->digits > ctx->prec) {
4277 /* Pad the result with trailing zeros if it has fewer digits than prec. */
4282 result->digits < ctx->prec) {
4283 mpd_ssize_t shift = ctx->prec - result->digits;
4375 * have any number of digits.
4416 t = a->digits + a->exp;
4541 ulpexp = result->exp + result->digits - workctx.prec;
4543 /* The effective work precision is result->digits. */
4727 result->exp = -(result->digits-1);
4874 a_digits = a->digits;
4886 * so 100 <= y <= 500. Since y contains the most significant digits
4893 * so 500 < y <= 999. Since y contains the most significant digits
4909 * significant digits.
4955 if (v.digits > varcontext.prec) {
4956 shift = v.digits - varcontext.prec;
5093 result->exp + result->digits-workctx.prec);
5242 result->exp + result->digits-workctx.prec);
6375 workctx.prec += (exp->digits + exp->exp + 2);
6469 /* digits-1 after exponentiation */
6668 workctx.prec = (base->digits > ctx->prec) ? base->digits : ctx->prec;
6863 if (mod->digits+mod->exp > ctx->prec) {
6994 if (a->digits + expdiff > ctx->prec) {
7007 /* At this point expdiff < 0 and a->digits+expdiff <= prec,
7166 qdigits = q.digits;
7223 if (a->digits + shift > MPD_MAX_PREC+1) {
7257 * result->digits <= MPD_MAX_PREC+1
7277 * result->digits <= MPD_MAX_PREC+1
7436 assert(v->exp == -v->digits);
7477 adj = v->digits + v->exp;
7478 v->exp = -v->digits;
7496 /* Loop invariant: z->digits <= klist[i]+7 */
7500 if (v->digits > varcontext.prec) {
7501 /* Let t := v, truncated to n >= 2*k+5 fraction digits */
7502 mpd_qshiftr(&t, v, v->digits-varcontext.prec, status);
7504 /* Let t := trunc(v)*s, truncated to n >= 2*k+1 fraction digits */
7507 else { /* v->digits <= 2*k+5 */
7508 /* Let t := v*s, truncated to n >= 2*k+1 fraction digits */
7513 /* s.digits < t.digits <= 2*k+5, |adjexp(s)-adjexp(t)| <= 1,
7515 * digits. The loop invariant is preserved. */
7577 workctx.prec = a->digits - b->digits + 1 + 3;
7578 if (a->digits > MPD_MAX_PREC || workctx.prec > MPD_MAX_PREC) {
7600 workctx.prec = aa.digits + 3;
7783 if ((v->digits+v->exp) & 1) {
7784 fracdigits = v->digits - 1;
7786 n = (v->digits > 7) ? 7 : (int)v->digits;
7794 fracdigits = v->digits - 2;
7796 n = (v->digits > 8) ? 8 : (int)v->digits;
7818 if (v->digits > varcontext.prec) {
7819 shift = v->digits - varcontext.prec;
7937 l = (a->digits >> 1) + 1;
7940 l = (a->digits + 1) >> 1;
8044 * If the result is exact, an upper bound for the number of digits
8045 * is the number of digits in the input.
8047 * NOTE: sqrt(40e9) = 2.0e+5 /\ digits(40e9) = digits(2.0e+5) = 2
8052 workctx.prec = a->digits;
8082 size_t digits;
8092 digits = a->digits+a->exp;
8096 if (digits > 2711437152599294ULL) {
8105 x = (double)digits / log10(base);