Home | History | Annotate | Download | only in Support

Lines Matching refs:Digits

11 // numbers -- in particular, pairs of integers where one represents digits and
47 /// Given \c Digits and \c Scale, round up iff \c ShouldRound is \c true.
53 inline std::pair<DigitsT, int16_t> getRounded(DigitsT Digits, int16_t Scale,
58 if (!++Digits)
61 return std::make_pair(Digits, Scale);
65 inline std::pair<uint32_t, int16_t> getRounded32(uint32_t Digits, int16_t Scale,
67 return getRounded(Digits, Scale, ShouldRound);
71 inline std::pair<uint64_t, int16_t> getRounded64(uint64_t Digits, int16_t Scale,
73 return getRounded(Digits, Scale, ShouldRound);
80 inline std::pair<DigitsT, int16_t> getAdjusted(uint64_t Digits,
85 if (Width == 64 || Digits <= std::numeric_limits<DigitsT>::max())
86 return std::make_pair(Digits, Scale);
89 int Shift = 64 - Width - countLeadingZeros(Digits);
90 return getRounded<DigitsT>(Digits >> Shift, Scale + Shift,
91 Digits & (UINT64_C(1) << (Shift - 1)));
95 inline std::pair<uint32_t, int16_t> getAdjusted32(uint64_t Digits,
97 return getAdjusted<uint32_t>(Digits, Scale);
101 inline std::pair<uint64_t, int16_t> getAdjusted64(uint64_t Digits,
103 return getAdjusted<uint64_t>(Digits, Scale);
157 "expected 32-bit or 64-bit digits");
184 /// Returns the rounded lg of \c Digits*2^Scale and an int specifying whether
187 /// Returns \c INT32_MIN when \c Digits is zero.
189 inline std::pair<int32_t, int> getLgImpl(DigitsT Digits, int16_t Scale) {
192 if (!Digits)
195 // Get the floor of the lg of Digits.
196 int32_t LocalFloor = sizeof(Digits) * 8 - countLeadingZeros(Digits) - 1;
200 if (Digits == UINT64_C(1) << LocalFloor)
205 bool Round = Digits & UINT64_C(1) << (LocalFloor - 1);
211 /// Get the lg of \c Digits*2^Scale.
213 /// Returns \c INT32_MIN when \c Digits is zero.
214 template <class DigitsT> int32_t getLg(DigitsT Digits, int16_t Scale) {
215 return getLgImpl(Digits, Scale).first;
220 /// Get the floor of the lg of \c Digits*2^Scale.
222 /// Returns \c INT32_MIN when \c Digits is zero.
223 template <class DigitsT> int32_t getLgFloor(DigitsT Digits, int16_t Scale) {
224 auto Lg = getLgImpl(Digits, Scale);
230 /// Get the ceiling of the lg of \c Digits*2^Scale.
232 /// Returns \c INT32_MIN when \c Digits is zero.
233 template <class DigitsT> int32_t getLgCeiling(DigitsT Digits, int16_t Scale) {
234 auto Lg = getLgImpl(Digits, Scale);
267 // Compare digits.
276 /// Given two scaled numbers, match up their scales. Change the digits and
277 /// scales in place. Shift the digits as necessary to form equivalent numbers,
342 // Normalize digits to match scales.
377 // Normalize digits to match scales.
448 /// ScaledNumber is a number represented by digits and a scale. It uses simple
455 /// The number is split into a signed scale and unsigned digits. The number
456 /// represented is \c getDigits()*2^getScale(). In this way, the digits are
460 /// ScaledNumber is templated on the underlying integer type for digits, which
504 static_assert(Width <= 64, "invalid integer width for digits");
507 DigitsType Digits;
511 ScaledNumber() : Digits(0), Scale(0) {}
513 ScaledNumber(DigitsType Digits, int16_t Scale)
514 : Digits(Digits), Scale(Scale) {}
518 : Digits(X.first), Scale(X.second) {}
535 DigitsType getDigits() const { return Digits; }
543 bool isZero() const { return !Digits; }
548 return Digits == DigitsType(1) << -Scale;
554 int32_t lg() const { return ScaledNumbers::getLg(Digits, Scale); }
559 int32_t lgFloor() const { return ScaledNumbers::getLgFloor(Digits, Scale); }
565 return ScaledNumbers::getLgCeiling(Digits, Scale);
583 /// \c Precision indicates the number of decimal digits of precision to use;
588 /// digits before the decimal place, it's printed accurately to the first
589 /// digit past zero. E.g., assuming 10 digits of precision:
597 return ScaledNumberBase::toString(Digits, Scale, Width, Precision);
605 return ScaledNumberBase::print(OS, Digits, Scale, Width, Precision);
607 void dump() const { return ScaledNumberBase::dump(Digits, Scale, Width); }
610 std::tie(Digits, Scale) =
611 ScaledNumbers::getSum(Digits, Scale, X.Digits, X.Scale);
618 std::tie(Digits, Scale) =
619 ScaledNumbers::getDifference(Digits, Scale, X.Digits, X.Scale);
645 ScaledNumbers::matchScales(Digits, Scale, X.Digits, X.Scale);
670 return ScaledNumbers::compare(Digits, Scale, X.Digits, X.Scale);
673 return ScaledNumbers::compare<uint64_t>(Digits, Scale, N, 0);
688 static int countLeadingZerosWidth(DigitsType Digits) {
690 return countLeadingZeros64(Digits);
692 return countLeadingZeros32(Digits);
693 return countLeadingZeros32(Digits) + Width - 32;
714 return ScaledNumbers::getRounded(P.Digits, P.Scale, Round);
776 return ScaledNumber<uint64_t>(Digits, Scale).scale(N);
788 IntT N = Digits;
812 *this = getProduct(Digits, X.Digits);
829 *this = getQuotient(Digits, X.Digits);
853 // Shift the digits themselves.
855 if (Shift > countLeadingZerosWidth(Digits)) {
861 Digits <<= Shift;
879 // Shift the digits themselves.
887 Digits >>= Shift;