Commit 90ef46df authored by Victor Zverovich's avatar Victor Zverovich

Fix dragonbox integration

parent 3ae88147
...@@ -2307,6 +2307,10 @@ FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT { ...@@ -2307,6 +2307,10 @@ FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
goto small_divisor_case_label; goto small_divisor_case_label;
} }
} }
if (ret_value.significand == 0) {
ret_value.exponent = 0;
return ret_value;
}
ret_value.exponent = minus_k + float_info<T>::kappa + 1; ret_value.exponent = minus_k + float_info<T>::kappa + 1;
// We may need to remove trailing zeros // We may need to remove trailing zeros
......
...@@ -1238,10 +1238,12 @@ TEST(FormatterTest, FormatConvertibleToLongLong) { ...@@ -1238,10 +1238,12 @@ TEST(FormatterTest, FormatConvertibleToLongLong) {
} }
TEST(FormatterTest, FormatFloat) { TEST(FormatterTest, FormatFloat) {
EXPECT_EQ("0", format("{}", 0.0f));
EXPECT_EQ("392.500000", format("{0:f}", 392.5f)); EXPECT_EQ("392.500000", format("{0:f}", 392.5f));
} }
TEST(FormatterTest, FormatDouble) { TEST(FormatterTest, FormatDouble) {
EXPECT_EQ("0", format("{}", 0.0));
check_unknown_types(1.2, "eEfFgGaAnL%", "double"); check_unknown_types(1.2, "eEfFgGaAnL%", "double");
EXPECT_EQ("0", format("{:}", 0.0)); EXPECT_EQ("0", format("{:}", 0.0));
EXPECT_EQ("0.000000", format("{:f}", 0.0)); EXPECT_EQ("0.000000", format("{:f}", 0.0));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment