Test that max_k is correctly defined

This commit is contained in:
Victor Zverovich
2020-09-23 15:12:03 -07:00
parent 51f8d0cc21
commit 6c025520aa
2 changed files with 18 additions and 4 deletions

View File

@@ -1198,10 +1198,11 @@ inline fp operator*(fp x, fp y) { return {multiply(x.f, y.f), x.e + y.e + 64}; }
// (binary) exponent satisfies `min_exponent <= c_k.e <= min_exponent + 28`.
inline fp get_cached_power(int min_exponent, int& pow10_exponent) {
const int shift = 32;
int index = static_cast<int>(((min_exponent + fp::significand_size - 1) *
(data::log10_2_significand >> shift) +
((int64_t(1) << shift) - 1)) // ceil
>> 32 // arithmetic shift
const auto significand = static_cast<int64_t>(data::log10_2_significand);
int index = static_cast<int>(
((min_exponent + fp::significand_size - 1) * (significand >> shift) +
((int64_t(1) << shift) - 1)) // ceil
>> 32 // arithmetic shift
);
// Decimal exponent of the first (smallest) cached power of 10.
const int first_dec_exp = -348;