diff --git a/include/fmt/format.h b/include/fmt/format.h index dbf92f1a..cd43119d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2249,7 +2249,7 @@ FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& fp, if (num_zeros > 0) size += to_unsigned(num_zeros); } auto grouping = Grouping(loc, fspecs.locale); - size += to_unsigned(grouping.count_separators(significand_size)); + size += to_unsigned(grouping.count_separators(exp)); return write_padded(out, specs, size, [&](iterator it) { if (sign) *it++ = detail::sign(sign); it = write_significand(it, significand, significand_size, diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 4386e8b9..0b0df9e3 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -370,10 +370,11 @@ template struct small_grouping : std::numpunct { TEST(locale_test, localized_double) { auto loc = std::locale(std::locale(), new numpunct()); - EXPECT_EQ("1?23", fmt::format(loc, "{:L}", 1.23)); - EXPECT_EQ("1?230000", fmt::format(loc, "{:Lf}", 1.23)); - EXPECT_EQ("1~234?5", fmt::format(loc, "{:L}", 1234.5)); - EXPECT_EQ("12~000", fmt::format(loc, "{:L}", 12000.0)); + EXPECT_EQ(fmt::format(loc, "{:L}", 1.23), "1?23"); + EXPECT_EQ(fmt::format(loc, "{:Lf}", 1.23), "1?230000"); + EXPECT_EQ(fmt::format(loc, "{:L}", 1234.5), "1~234?5"); + EXPECT_EQ(fmt::format(loc, "{:L}", 12000.0), "12~000"); + EXPECT_EQ(fmt::format(loc, "{:8L}", 1230.0), " 1~230"); } TEST(locale_test, format) {