MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / get_cached_power

Function get_cached_power

extlibs/fmt/include/fmt/format-inl.h:463–477  ·  view source on GitHub ↗

Returns a cached power of 10 `c_k = c_k.f * pow(2, c_k.e)` such that its (binary) exponent satisfies `min_exponent <= c_k.e <= min_exponent + 28`.

Source from the content-addressed store, hash-verified

461// Returns a cached power of 10 `c_k = c_k.f * pow(2, c_k.e)` such that its
462// (binary) exponent satisfies `min_exponent <= c_k.e <= min_exponent + 28`.
463inline fp get_cached_power(int min_exponent, int& pow10_exponent) {
464 const int64_t one_over_log2_10 = 0x4d104d42; // round(pow(2, 32) / log2(10))
465 int index = static_cast<int>(
466 ((min_exponent + fp::significand_size - 1) * one_over_log2_10 +
467 ((int64_t(1) << 32) - 1)) // ceil
468 >> 32 // arithmetic shift
469 );
470 // Decimal exponent of the first (smallest) cached power of 10.
471 const int first_dec_exp = -348;
472 // Difference between 2 consecutive decimal exponents in cached powers of 10.
473 const int dec_exp_step = 8;
474 index = (index - first_dec_exp - 1) / dec_exp_step + 1;
475 pow10_exponent = first_dec_exp + index * dec_exp_step;
476 return {data::pow10_significands[index], data::pow10_exponents[index]};
477}
478
479// A simple accumulator to hold the sums of terms in bigint::square if uint128_t
480// is not available.

Callers 1

format_floatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected