Add cached powers of 10
This commit is contained in:
@@ -263,10 +263,10 @@ inline fp operator-(fp x, fp y) {
|
||||
fp operator*(fp x, fp y);
|
||||
|
||||
// Compute k such that its cached power c_k = c_k.f * pow(2, c_k.e) satisfies
|
||||
// alpha <= c_k.e + e <= alpha + 3.
|
||||
inline int compute_cached_power_index(int e, int alpha) {
|
||||
// min_exponent <= c_k.e + e <= min_exponent + 3.
|
||||
inline int compute_cached_power_index(int e, int min_exponent) {
|
||||
constexpr double one_over_log2_10 = 0.30102999566398114; // 1 / log2(10)
|
||||
return static_cast<int>(std::ceil((alpha - e + 63) * one_over_log2_10));
|
||||
return static_cast<int>(std::ceil((min_exponent - e + 63) * one_over_log2_10));
|
||||
}
|
||||
|
||||
template <typename Allocator>
|
||||
@@ -795,6 +795,8 @@ template <typename T = void>
|
||||
struct FMT_API basic_data {
|
||||
static const uint32_t POWERS_OF_10_32[];
|
||||
static const uint64_t POWERS_OF_10_64[];
|
||||
static const uint64_t POW10_SIGNIFICANDS[];
|
||||
static const int16_t POW10_EXPONENTS[];
|
||||
static const char DIGITS[];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user