Implement simple version of Grisu

This commit is contained in:
Victor Zverovich
2018-05-28 11:25:07 -07:00
parent 4027557958
commit 4e4b8570e5
2 changed files with 103 additions and 57 deletions

View File

@@ -346,7 +346,7 @@ FMT_FUNC fp operator*(fp x, fp y) {
FMT_FUNC fp get_cached_power(int min_exponent, int &pow10_exponent) {
const double one_over_log2_10 = 0.30102999566398114; // 1 / log2(10)
int index = static_cast<int>(std::ceil(
(min_exponent + fp::fp_significand_size - 1) * one_over_log2_10));
(min_exponent + fp::significand_size - 1) * one_over_log2_10));
// Decimal exponent of the first (smallest) cached power of 10.
const int first_dec_exp = -348;
// Difference between two consecutive decimal exponents in cached powers of 10.