mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Fix localized format for float-point numbers (#3272)
This commit is contained in:
parent
0f42c17d85
commit
39971eb336
@ -2637,7 +2637,7 @@ FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& f,
|
||||
int num_zeros = fspecs.showpoint ? fspecs.precision - significand_size : 0;
|
||||
size += 1 + to_unsigned(num_zeros > 0 ? num_zeros : 0);
|
||||
auto grouping = Grouping(loc, fspecs.locale);
|
||||
size += to_unsigned(grouping.count_separators(significand_size));
|
||||
size += to_unsigned(grouping.count_separators(exp));
|
||||
return write_padded<align::right>(out, specs, size, [&](iterator it) {
|
||||
if (sign) *it++ = detail::sign<Char>(sign);
|
||||
it = write_significand(it, significand, significand_size, exp,
|
||||
|
@ -438,6 +438,9 @@ TEST(locale_test, localized_double) {
|
||||
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");
|
||||
EXPECT_EQ(fmt::format(loc, "{:15.6Lf}", 0.1), " 0?100000");
|
||||
EXPECT_EQ(fmt::format(loc, "{:15.6Lf}", 1.0), " 1?000000");
|
||||
EXPECT_EQ(fmt::format(loc, "{:15.6Lf}", 1e3), " 1~000?000000");
|
||||
}
|
||||
|
||||
TEST(locale_test, format) {
|
||||
|
Loading…
Reference in New Issue
Block a user