From 22a68d1613bdd01a1030c090567de59e0ef53f4b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 27 Nov 2020 07:45:54 -0800 Subject: [PATCH] Don't emit trailing zeros by default --- include/fmt/format.h | 1 - test/format-test.cc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index f47f6427..a91578a8 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1396,7 +1396,6 @@ FMT_CONSTEXPR float_specs parse_float_type_spec( switch (specs.type) { case 0: result.format = float_format::general; - result.showpoint |= specs.precision > 0; break; case 'G': result.upper = true; diff --git a/test/format-test.cc b/test/format-test.cc index 49886eaf..205997ec 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -978,6 +978,7 @@ TEST(FormatterTest, Precision) { EXPECT_EQ("1.2", format("{0:.2}", 1.2345)); EXPECT_EQ("1.2", format("{0:.2}", 1.2345l)); EXPECT_EQ("1.2e+56", format("{:.2}", 1.234e56)); + EXPECT_EQ("1.1", format("{0:.3}", 1.1)); EXPECT_EQ("1e+00", format("{:.0e}", 1.0L)); EXPECT_EQ(" 0.0e+00", format("{:9.1e}", 0.0)); EXPECT_EQ(