Fix handling of zero precision

This commit is contained in:
Victor Zverovich
2022-02-18 12:38:30 -08:00
parent b6d56170fc
commit 2c8cd2db34
3 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -2246,7 +2246,8 @@ FMT_HEADER_ONLY_CONSTEXPR20 int format_float(Float value, int precision,
precision = handler.precision;
}
} else {
exp = static_cast<int>(std::log10(value));
// Use floor because 0.9 = 9e-1.
exp = static_cast<int>(std::floor(std::log10(value)));
if (fixed) adjust_precision(precision, exp + 1);
}
if (use_dragon) {