Fix handling of zero precision
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -2256,6 +2256,8 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value,
|
||||
throw_format_error("number is too big");
|
||||
else
|
||||
++precision;
|
||||
} else if (fspecs.format != float_format::fixed && precision == 0) {
|
||||
precision = 1;
|
||||
}
|
||||
if (const_check(std::is_same<T, float>())) fspecs.binary32 = true;
|
||||
if (!std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::digits > 64)
|
||||
|
||||
Reference in New Issue
Block a user