mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 03:07:36 +02:00
Fix carry in fallback_format
This commit is contained in:
@ -2545,7 +2545,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer<char>& buf,
|
|||||||
++buf[i - 1];
|
++buf[i - 1];
|
||||||
}
|
}
|
||||||
if (buf[0] == overflow) {
|
if (buf[0] == overflow) {
|
||||||
buf[0] = '0';
|
buf[0] = '1';
|
||||||
++exp10;
|
++exp10;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -957,6 +957,7 @@ TEST(FormatterTest, Precision) {
|
|||||||
EXPECT_EQ("1.23", format("{:.02f}", 1.234));
|
EXPECT_EQ("1.23", format("{:.02f}", 1.234));
|
||||||
EXPECT_EQ("0.001", format("{:.1g}", 0.001));
|
EXPECT_EQ("0.001", format("{:.1g}", 0.001));
|
||||||
EXPECT_EQ("1019666400", format("{}", 1019666432.0f));
|
EXPECT_EQ("1019666400", format("{}", 1019666432.0f));
|
||||||
|
EXPECT_EQ("1e+01", format("{:.0e}", 9.5));
|
||||||
|
|
||||||
EXPECT_THROW_MSG(format("{0:.2}", reinterpret_cast<void*>(0xcafe)),
|
EXPECT_THROW_MSG(format("{0:.2}", reinterpret_cast<void*>(0xcafe)),
|
||||||
format_error,
|
format_error,
|
||||||
|
Reference in New Issue
Block a user