Lines Matching defs:Digits

46 /// Given \c Digits and \c Scale, round up iff \c ShouldRound is \c true.
52 inline std::pair<DigitsT, int16_t> getRounded(DigitsT Digits, int16_t Scale,
57 if (!++Digits)
60 return std::make_pair(Digits, Scale);
64 inline std::pair<uint32_t, int16_t> getRounded32(uint32_t Digits, int16_t Scale,
66 return getRounded(Digits, Scale, ShouldRound);
70 inline std::pair<uint64_t, int16_t> getRounded64(uint64_t Digits, int16_t Scale,
72 return getRounded(Digits, Scale, ShouldRound);
79 inline std::pair<DigitsT, int16_t> getAdjusted(uint64_t Digits,
84 if (Width == 64 || Digits <= std::numeric_limits<DigitsT>::max())
85 return std::make_pair(Digits, Scale);
88 int Shift = 64 - Width - countLeadingZeros(Digits);
89 return getRounded<DigitsT>(Digits >> Shift, Scale + Shift,
90 Digits & (UINT64_C(1) << (Shift - 1)));
94 inline std::pair<uint32_t, int16_t> getAdjusted32(uint64_t Digits,
96 return getAdjusted<uint32_t>(Digits, Scale);
100 inline std::pair<uint64_t, int16_t> getAdjusted64(uint64_t Digits,
102 return getAdjusted<uint64_t>(Digits, Scale);
183 /// Returns the rounded lg of \c Digits*2^Scale and an int specifying whether
186 /// Returns \c INT32_MIN when \c Digits is zero.
188 inline std::pair<int32_t, int> getLgImpl(DigitsT Digits, int16_t Scale) {
191 if (!Digits)
194 // Get the floor of the lg of Digits.
195 int32_t LocalFloor = sizeof(Digits) * 8 - countLeadingZeros(Digits) - 1;
199 if (Digits == UINT64_C(1) << LocalFloor)
204 bool Round = Digits & UINT64_C(1) << (LocalFloor - 1);
210 /// Get the lg of \c Digits*2^Scale.
212 /// Returns \c INT32_MIN when \c Digits is zero.
213 template <class DigitsT> int32_t getLg(DigitsT Digits, int16_t Scale) {
214 return getLgImpl(Digits, Scale).first;
219 /// Get the floor of the lg of \c Digits*2^Scale.
221 /// Returns \c INT32_MIN when \c Digits is zero.
222 template <class DigitsT> int32_t getLgFloor(DigitsT Digits, int16_t Scale) {
223 auto Lg = getLgImpl(Digits, Scale);
229 /// Get the ceiling of the lg of \c Digits*2^Scale.
231 /// Returns \c INT32_MIN when \c Digits is zero.
232 template <class DigitsT> int32_t getLgCeiling(DigitsT Digits, int16_t Scale) {
233 auto Lg = getLgImpl(Digits, Scale);
506 DigitsType Digits = 0;
512 constexpr ScaledNumber(DigitsType Digits, int16_t Scale)
513 : Digits(Digits), Scale(Scale) {}
517 : Digits(X.first), Scale(X.second) {}
534 DigitsType getDigits() const { return Digits; }
542 bool isZero() const { return !Digits; }
547 return Digits == DigitsType(1) << -Scale;
553 int32_t lg() const { return ScaledNumbers::getLg(Digits, Scale); }
558 int32_t lgFloor() const { return ScaledNumbers::getLgFloor(Digits, Scale); }
564 return ScaledNumbers::getLgCeiling(Digits, Scale);
596 return ScaledNumberBase::toString(Digits, Scale, Width, Precision);
604 return ScaledNumberBase::print(OS, Digits, Scale, Width, Precision);
606 void dump() const { return ScaledNumberBase::dump(Digits, Scale, Width); }
609 std::tie(Digits, Scale) =
610 ScaledNumbers::getSum(Digits, Scale, X.Digits, X.Scale);
617 std::tie(Digits, Scale) =
618 ScaledNumbers::getDifference(Digits, Scale, X.Digits, X.Scale);
644 ScaledNumbers::matchScales(Digits, Scale, X.Digits, X.Scale);
669 return ScaledNumbers::compare(Digits, Scale, X.Digits, X.Scale);
672 return ScaledNumbers::compare<uint64_t>(Digits, Scale, N, 0);
687 static int countLeadingZerosWidth(DigitsType Digits) {
689 return countLeadingZeros64(Digits);
691 return countLeadingZeros32(Digits);
692 return countLeadingZeros32(Digits) + Width - 32;
713 return ScaledNumbers::getRounded(P.Digits, P.Scale, Round);
775 return ScaledNumber<uint64_t>(Digits, Scale).scale(N);
787 IntT N = Digits;
811 *this = getProduct(Digits, X.Digits);
828 *this = getQuotient(Digits, X.Digits);
854 if (Shift > countLeadingZerosWidth(Digits)) {
860 Digits <<= Shift;
886 Digits >>= Shift;