Skip to content

Commit

Permalink
Fix fixed precision handling during rounding in long double
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Aug 7, 2023
1 parent 3c1b333 commit d424862
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,8 @@ FMT_CONSTEXPR20 inline void format_dragon(basic_fp<uint128_t> value,
}
if (buf[0] == overflow) {
buf[0] = '1';
++exp10;
if ((flags & dragon::fixed) != 0) buf.push_back('0');
else ++exp10;
}
return;
}
Expand Down
1 change: 1 addition & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ TEST(format_test, format_long_double) {
EXPECT_EQ("0", fmt::format("{0:}", 0.0l));
EXPECT_EQ("0.000000", fmt::format("{0:f}", 0.0l));
EXPECT_EQ("0.0", fmt::format("{:.1f}", 0.000000001l));
EXPECT_EQ("0.10", fmt::format("{:.2f}", 0.099l));
EXPECT_EQ("392.65", fmt::format("{0:}", 392.65l));
EXPECT_EQ("392.65", fmt::format("{0:g}", 392.65l));
EXPECT_EQ("392.65", fmt::format("{0:G}", 392.65l));
Expand Down

0 comments on commit d424862

Please sign in to comment.