diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 5d466eeb..8f2fe735 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2337,7 +2337,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer& buf, upper = &upper_store; } denominator.assign_pow10(exp10); - denominator <<= 1; + denominator <<= shift; } else if (exp10 < 0) { numerator.assign_pow10(-exp10); lower.assign(numerator); diff --git a/test/format-test.cc b/test/format-test.cc index 128b57a2..0f87a23c 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1270,6 +1270,8 @@ TEST(FormatterTest, FormatDouble) { EXPECT_EQ(buffer, format("{:a}", -42.0)); safe_sprintf(buffer, "%A", -42.0); EXPECT_EQ(buffer, format("{:A}", -42.0)); + EXPECT_EQ("9223372036854775808.000000", + format("{:f}", 9223372036854775807.0)); } TEST(FormatterTest, PrecisionRounding) {