Skip to content

Commit

Permalink
%.f should have zero precision, not default precision
Browse files Browse the repository at this point in the history
  • Loading branch information
manylegged authored and vitaut committed Apr 8, 2017
1 parent c03f55e commit cbac016
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ void PrintfFormatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
} else if (*s == '*') {
++s;
spec.precision_ = internal::PrecisionHandler().visit(get_arg(s));
} else {
spec.precision_ = 0;
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/printf-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ TEST(PrintfTest, LongLong) {

TEST(PrintfTest, Float) {
EXPECT_PRINTF("392.650000", "%f", 392.65);
EXPECT_PRINTF("392.65", "%.2f", 392.65);
EXPECT_PRINTF("392.6", "%.1f", 392.65);
EXPECT_PRINTF("393", "%.f", 392.65);
EXPECT_PRINTF("392.650000", "%F", 392.65);
EXPECT_PRINTF("392.65", "%s", 392.65);
char buffer[BUFFER_SIZE];
Expand Down

0 comments on commit cbac016

Please sign in to comment.