mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Fix handling of zero precision
This commit is contained in:
parent
6b20863918
commit
946498cfbc
@ -610,7 +610,7 @@ struct fixed_handler {
|
||||
uint64_t error, int, bool integral) {
|
||||
FMT_ASSERT(remainder < divisor, "");
|
||||
buf[size++] = digit;
|
||||
if (size != precision) return digits::more;
|
||||
if (size < precision) return digits::more;
|
||||
if (!integral) {
|
||||
// Check if error * 2 < divisor with overflow prevention.
|
||||
// The check is not needed for the integral part because error = 1
|
||||
|
@ -52,3 +52,7 @@ TEST(GrisuTest, Prettify) {
|
||||
EXPECT_EQ("12.34", fmt::format("{}", 1234e-2));
|
||||
EXPECT_EQ("0.001234", fmt::format("{}", 1234e-6));
|
||||
}
|
||||
|
||||
TEST(GrisuTest, ZeroPrecision) {
|
||||
EXPECT_EQ("1", fmt::format("{:.0}", 1.0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user