Lines Matching refs:digits

57 /*    precision (up to 999,999,999 digits) and arbitrary exponent     */
137 /* 6. The digits count is allowed to rise to a multiple of DECDPUN */
139 /* accounting of digits is not needed. The correct digits value */
141 /* This must be called before any rounding if the number of digits */
145 /* numbers up to four digits, using appropriate constants. This */
313 /* string must be at least dn->digits+14 characters long */
339 /* (set.digits), determining the maximum and minimum */
360 Int d = 0; /* count of digits found in decimal part */
395 d++; /* count of real digits */
410 { /* no decimal digits, or >1 . */
464 break; /* not all digits */
465 if (d > set->digits)
466 break; /* too many digits */
555 /* OK, the digits string is good. Copy to the decNumber, or to
557 if (d <= set->digits)
578 i = d % DECDPUN; /* digits in top unit */
584 { /* along the digits */
615 dn->digits = d;
618 if (d > set->digits)
647 /* C must have space for set->digits digits. */
681 /* C must have space for set->digits digits. */
728 /* C must have space for set->digits digits. */
751 /* C must have space for set->digits digits. */
774 /* C must have space for set->digits digits. */
797 /* C must have space for set->digits digits. */
819 /* C must have space for set->digits digits. */
851 /* C must have space for set->digits digits. */
886 /* C must have space for set->digits digits. */
908 /* C must have space for set->digits digits. */
929 if (rhs->digits > set->digits)
971 /* C must have space for set->digits digits. */
983 Int reqdigits = set->digits; /* requested DIGITS */
996 /* local accumulator buffer [a decNumber, with digits+elength+1 digits] */
1013 if (lhs->digits > reqdigits)
1022 if (rhs->digits > reqdigits)
1085 workset.digits = reqdigits + (inrhs->digits + inrhs->exponent) + 1;
1087 if (workset.digits > DECNUMMAXP)
1093 /* workset.digits is the count of digits for the accumulator we need */
1096 sizeof (decNumber) + (D2U (workset.digits) - 1) * sizeof (Unit);
1128 { /* was a **-n [hence digits>0] */
1207 /* round subnormals [to set.digits rather than workset.digits] */
1217 { /* was a **-n [hence digits>0] */
1257 /* C must have space for set->digits digits. */
1286 /* C must have space for set->digits digits. */
1312 /* C must have space for set->digits digits. */
1335 /* C must have space for set->digits digits. */
1394 /* C must have space for set->digits digits. */
1459 Int maxp = set->digits + 2; /* largest working precision */
1480 /* buffer for temporary variable, up to 3 digits */
1495 if (rhs->digits > set->digits)
1550 sizeof (decNumber) + (D2U (rhs->digits) - 1) * sizeof (Unit);
1578 exp = f->exponent + f->digits; /* adjusted to Hull rules */
1579 f->exponent = -(f->digits); /* to range */
1585 approxset.digits = set->digits; /* approx's length */
1591 workset.digits = set->digits; /* p for initial calculation */
1593 t->digits = 3;
1595 a->digits = 3;
1652 workset.digits = 3; /* initial p */
1656 workset.digits = workset.digits * 2 - 2;
1657 if (workset.digits > maxp)
1658 workset.digits = maxp;
1666 if (workset.digits == maxp)
1673 /* Here workset.digits=maxp and t=0.5 */
1674 workset.digits--; /* maxp-1 is OK now */
1675 t->exponent = -set->digits - 1; /* make 0.5 ulp */
1720 /* it is short enough so that squaring it could fit in set->digits, */
1723 if (b->digits * 2 - 1 > set->digits)
1758 decShiftToLeast (a->lsu, D2U (a->digits), todrop);
1760 a->digits -= todrop; /* new length */
1793 /* C must have space for set->digits digits. */
1822 /* the digits setting is ignored. */
1853 workset.digits = rhs->digits; /* no length rounding */
1892 dest->digits = src->digits;
1894 if (src->digits > DECDPUN)
1901 smsup = src->lsu + D2U (src->digits); /* -> source msu+1 */
1955 dn->digits = 1;
1971 /* str must be at least dn->digits+14 characters long */
2007 Int pre; /* digits before the '.' */
2008 Int cut; /* for counting digits in a Unit */
2010 const Unit *up = dn->lsu + D2U (dn->digits) - 1; /* -> msu [input pointer] */
2043 if (exp != 0 || (*dn->lsu == 0 && dn->digits == 1))
2048 /* calculate how many digits in msu, and hence first cut */
2049 cut = dn->digits % DECDPUN;
2059 u = *up; /* contains DECDPUN digits to lay out */
2062 cut = DECDPUN - 1; /* next Unit has all digits */
2069 pre = dn->digits + exp; /* digits before '.' */
2073 e = exp + dn->digits - 1; /* calculate E value */
2107 /* lay out the digits of the coefficient, adding 0s and . as needed */
2116 break; /* out of input digits (pre>digits) */
2132 break; /* out of input digits */
2157 break; /* out of input digits */
2208 /* C must have space for set->digits digits. */
2212 /* -- we need a digits+1 calculation because numbers are unaligned */
2213 /* and span more than set->digits digits */
2214 /* -- a carry to digits+1 digits looks possible */
2246 Int reqdigits = set->digits; /* local copy; requested DIGITS */
2261 if (lhs->digits > reqdigits)
2269 if (rhs->digits > reqdigits)
2343 if ((res->digits - adjust) > set->digits)
2345 adjust = res->digits - set->digits; /* to fit exactly */
2348 res->digits =
2349 decShiftToMost (res->lsu, res->digits, -adjust);
2376 if ((res->digits - adjust) > set->digits)
2378 adjust = res->digits - set->digits; /* to fit exactly */
2381 res->digits =
2382 decShiftToMost (res->lsu, res->digits, -adjust);
2400 if (rhs->digits <= DECDPUN && padding == 0 && rhs->exponent >= set->emin /* [some normals drop through] */
2401 && rhs->digits <= reqdigits && lhs->digits <= reqdigits)
2407 if (lhs->digits < DECDPUN)
2408 maxv = powers[lhs->digits] - 1;
2427 /* this could have reduced digits [but result>0] */
2428 res->digits = decGetDigits (res->lsu, D2U (res->digits));
2464 /* If, after pad, rhs would be longer than lhs by digits+1 or */
2467 if (rhs->digits + padding > lhs->digits + reqdigits + 1)
2471 Int shift = reqdigits - rhs->digits; /* left shift needed */
2480 res->digits = decShiftToMost (res->lsu, res->digits, shift);
2490 /* LHS digits may affect result */
2499 maxdigits = rhs->digits + padding; /* virtual length of RHS */
2500 if (lhs->digits > maxdigits)
2501 maxdigits = lhs->digits;
2513 /* we'll need units for maxdigits digits, +1 Unit for carry or borrow */
2533 decDumpAr ('A', lhs->lsu, D2U (lhs->digits));
2534 decDumpAr ('B', rhs->lsu, D2U (rhs->digits));
2539 res->digits = decUnitAddSub (lhs->lsu, D2U (lhs->digits), rhs->lsu, D2U (rhs->digits), rhsshift, acc, mult) * DECDPUN; /* [units -> digits] */
2540 if (res->digits < 0)
2542 res->digits = -res->digits;
2546 decDumpAr ('+', acc, D2U (res->digits));
2561 if (res->digits > reqdigits)
2562 res->digits = decGetDigits (acc, D2U (res->digits));
2563 decSetCoeff (res, set, acc, res->digits, &residue, status);
2569 /* numbers fit in DECDPUN digits and we are padding with a */
2573 if (res->digits < maxdigits)
2575 *(acc + D2U (res->digits)) = 0; /* ensure leading 0 is there */
2576 res->digits = maxdigits;
2583 if (res->digits > reqdigits)
2585 res->digits = decGetDigits (acc, D2U (res->digits));
2586 if (res->digits < maxdigits)
2587 res->digits = maxdigits;
2590 decSetCoeff (res, set, acc, res->digits, &residue, status);
2603 res->digits = decGetDigits (res->lsu, D2U (res->digits));
2653 /* C must have space for set->digits digits. */
2672 /* Do until (have=digits+1 OR residue=0) */
2701 /* We need two working buffers during the long division; one (digits+ */
2702 /* 1) to accumulate the result, and the other (up to 2*digits+1) for */
2719 Int accdigits; /* count of digits accumulated */
2729 Int var1initpad = 0; /* var1 initial padding (digits) */
2738 Int reqdigits = set->digits; /* requested DIGITS */
2762 if (lhs->digits > reqdigits)
2769 if (rhs->digits > reqdigits)
2821 res->exponent = set->emin - set->digits + 1;
2893 (lhs->exponent + lhs->digits) - (rhs->exponent + rhs->digits);
2946 /* (rhs->digits+reqdigits-1) -- to allow full slide to right */
2947 /* or (lhs->digits) -- to allow for long lhs */
2953 maxdigits = rhs->digits + reqdigits - 1;
2954 if (lhs->digits > maxdigits)
2955 maxdigits = lhs->digits;
2977 source = lhs->lsu + D2U (lhs->digits) - 1; /* msu of input array */
2985 var2units = D2U (rhs->digits); /* rhs actual length (units) */
3006 /* [We actually do this by counting the digits and negating, as */
3021 /* save the initial 'false' padding of var1, in digits */
3022 var1initpad = (var1units - D2U (lhs->digits)) * DECDPUN;
3049 accdigits = 0; /* .. or digits */
3050 accnext = acc + acclength - 1; /* -> msu of acc [NB: allows digits+1] */
3134 /* account exactly for the digits we got */
3150 /* divideInteger and we haven't got enough digits yet) */
3174 /* accunits is the number of digits we collected in acc */
3266 /* calculate the unused zero digits. This is the smaller of: */
3275 /* shift var1 the requested amount, and adjust its digits */
3308 D2U (rhs->digits),
3352 quotdigits -= DECDPUN; /* checked those digits */
3369 rhs->lsu, D2U (rhs->digits),
3372 accdigits = decGetDigits (accnext, accunits); /* count digits exactly */
3420 /* C must have space for set->digits digits. */
3459 if (lhs->digits > set->digits)
3466 if (rhs->digits > set->digits)
3503 if (lhs->digits < rhs->digits)
3511 need = D2U (lhs->digits) + D2U (rhs->digits); /* maximum units in result */
3531 madlength = D2U (lhs->digits); /* we know this won't change */
3532 mermsup = rhs->lsu + D2U (rhs->digits); /* -> msu+1 of multiplier */
3561 res->digits = decGetDigits (acc, accunits); /* count digits exactly */
3574 decSetCoeff (res, set, acc, res->digits, &residue, status);
3606 /* C must have space for set->digits digits. */
3618 Int reqdigits = set->digits; /* requested DIGITS */
3622 Int etiny = set->emin - (set->digits - 1);
3635 if (lhs->digits > reqdigits)
3642 if (rhs->digits > reqdigits)
3709 if ((lhs->digits - adjust) > reqdigits)
3718 /* digits, and must round as it does so */
3721 workset.digits = lhs->digits - adjust; /* set requested length */
3730 res->digits = decShiftToMost (res->lsu, res->digits, 1); /* shift */
3741 /* digits, by adding trailing zeros. */
3746 res->digits =
3747 decShiftToMost (res->lsu, res->digits, -adjust);
3755 if (res->exponent > set->emax - res->digits + 1)
3788 /* C must have space for one digit for COMPARE or set->digits for */
3815 if (lhs->digits > set->digits)
3825 if (rhs->digits > set->digits)
4002 compare = decUnitCompare (lhs->lsu, D2U (lhs->digits),
4003 rhs->lsu, D2U (rhs->digits),
4203 /* here carry is new Unit of digits; it could be +ve or -ve */
4267 /* here carry is new Unit of digits; it could be +ve or -ve and */
4394 for (d = 0; d < dn->digits - 1; d++)
4427 decShiftToLeast (dn->lsu, D2U (dn->digits), d);
4429 dn->digits -= d; /* new length */
4435 /* decShiftToMost -- shift digits in array towards most significant */
4438 /* digits is the count of digits in use in the array */
4442 /* returns the new length of the integer in the array, in digits */
4448 decShiftToMost (Unit * uar, Int digits, Int shift)
4456 return digits; /* [fastpath] nothing to do */
4457 if ((digits + shift) <= DECDPUN)
4460 return digits + shift;
4464 source = uar + D2U (digits) - 1; /* where msu comes from */
4465 first = uar + D2U (digits + shift) - 1; /* where msu of source will end up */
4490 return digits + shift;
4494 /* decShiftToLeast -- shift digits in array towards least significant */
4498 /* shift is the number of digits to remove from the lsu end; it */
4503 /* Removed digits are discarded (lost). Units not required to hold */
4559 /* dn is the number to round (dn->digits is > set->digits) */
4584 + (D2U (set->digits) - 1) * sizeof (Unit));
4593 /* If that set Inexact then we "lost digits" */
4606 /* set is the context [used for length (digits) and rounding mode] */
4619 decSetCoeff (dest, set, src->lsu, src->digits, residue, status);
4626 /* It must have space for set->digits digits */
4629 /* len is digits in the source coefficient [may be dn->digits] */
4634 /* reflect the previous residue and the dropped digits. */
4639 /* dn->lsu and len must == dn->digits. */
4641 /* Note that the coefficient length (len) may be < set->digits, and */
4646 /* decSetSubnormal) the value of set->digits may be less than one, */
4650 /* dn->digits, dn->lsu (and as required), and dn->exponent are */
4653 /* DEC_Rounded status is set if any digits are discarded. */
4654 /* DEC_Inexact status is set if any non-zero digits are discarded, or */
4665 Int discard; /* number of digits to discard */
4676 discard = len - set->digits; /* digits to discard */
4678 { /* no digits are being discarded */
4687 dn->digits = len; /* set the new length */
4695 /* we have to discard some digits */
4716 dn->digits = 1; /* .. */
4786 /* quot holds the uncut high-order digits for the current */
4789 count = set->digits; /* digits to end up with */
4793 dn->digits = 1; /* .. */
4798 dn->digits = count; /* set the new length */
4844 /* dn is the number, with space for set->digits digits */
4852 /* -1: as 1, but the hidden digits are subtractive, that */
4982 uInt count = dn->digits; /* digits to be checked */
4996 if ((dn->exponent + dn->digits) > set->emax + 1)
5011 /* all other digits zero) */
5013 uInt count = dn->digits; /* digits to be checked */
5033 /* dn->exponent, set->digits); */
5034 if (dn->exponent + 1 == set->emin - set->digits + 1)
5036 if (count == 1 && dn->digits == 1)
5041 dn->digits--;
5059 decUnitAddSub (dn->lsu, D2U (dn->digits), one, 1, 0, dn->lsu, bump);
5074 /* b. Reducing positive exponents to 0, if would fit in digits */
5094 if (set->digits >= (dn->exponent + dn->digits))
5096 dn->digits = decShiftToMost (dn->lsu, dn->digits, dn->exponent);
5132 && (dn->exponent < set->emin - dn->digits + 1))
5144 if (dn->exponent <= set->emax - set->digits + 1)
5148 if (dn->exponent > set->emax - dn->digits + 1)
5158 shift = dn->exponent - (set->emax - set->digits + 1);
5163 dn->digits = decShiftToMost (dn->lsu, dn->digits, shift);
5191 emax -= set->digits - 1; /* lower if clamping */
5226 Int count = set->digits; /* nines to add */
5227 dn->digits = count;
5238 count -= DECDPUN; /* we filled those digits */
5241 dn->exponent = set->emax - set->digits + 1;
5285 etiny = set->emin - (set->digits - 1); /* smallest allowed exponent */
5308 adjust = etiny - dn->exponent; /* calculate digits to remove */
5328 workset.digits = dn->digits - adjust; /* set requested length */
5331 decSetCoeff (dn, &workset, dn->lsu, dn->digits, residue, status);
5343 dn->digits = decShiftToMost (dn->lsu, dn->digits, 1);
5352 /* set is the context [requested digits], subset only */
5358 /* If subset it must also fit in set->digits */
5371 Int got; /* digits (real or not) processed */
5372 Int ilength = dn->digits + dn->exponent; /* integral length */
5374 /* The number must be an integer that fits in 10 digits */
5387 if (!set->extended && ilength > set->digits)
5400 Int count = -dn->exponent; /* digits to discard */
5413 /* slice off fraction digits and check for non-zero */
5424 got = DECDPUN - count; /* number of digits so far */
5550 /* decGetDigits -- count digits in a Units array */
5556 /* returns the number of (significant) digits in the array */
5566 Int digits = len * DECDPUN; /* maximum possible digits */
5571 digits -= DECDPUN;
5574 if (digits != 0)
5577 digits++; /* .. so bump digits to 1 */
5581 digits++;
5584 digits++;
5586 digits++;
5590 return digits;
5599 /* Shows: sign, exponent, coefficient (msu first), digits */
5630 if (dn->exponent == 0 && dn->digits == 1 && *dn->lsu == 0)
5640 up = dn->lsu + D2U (dn->digits) - 1; /* msu */
5660 printf (" [%d]\n", dn->digits);
5721 && (set->digits < 1 || set->round < 0
5726 printf ("Bad context [digits=%d round=%d].\n", set->digits, set->round);
5770 Int ae, d, digits; /* .. */
5795 if (dn->digits != 1)
5798 printf ("Digits %d (not 1) for an infinity.\n", dn->digits);
5823 if (dn->digits < 1 || dn->digits > DECNUMMAXP)
5826 printf ("Digits %d in number.\n", dn->digits);
5831 d = dn->digits;
5840 if (dn->digits > 1 && *up < powers[d - 1])
5861 /* which are out of the set->emin/set->emax and set->digits range */
5862 /* (just as they can have more digits than set->digits). */
5863 ae = dn->exponent + dn->digits - 1; /* adjusted exponent */
5866 digits = DECNUMMAXP;
5867 if (ae < emin - (digits - 1))