diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7ffda020..e4039e52 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2258,6 +2258,9 @@ FMT_SAFEBUFFERS decimal_fp to_decimal(T x) FMT_NOEXCEPT { (static_cast(1) << float_info::significand_bits); } else { // Subnormal case; the interval is always regular. + if (significand == 0) { + return decimal_fp{0, 0}; + } exponent = float_info::min_exponent - float_info::significand_bits; } @@ -2307,10 +2310,6 @@ FMT_SAFEBUFFERS decimal_fp to_decimal(T x) FMT_NOEXCEPT { goto small_divisor_case_label; } } - if (ret_value.significand == 0) { - ret_value.exponent = 0; - return ret_value; - } ret_value.exponent = minus_k + float_info::kappa + 1; // We may need to remove trailing zeros