Commit ce98e0c6 authored by Victor Zverovich's avatar Victor Zverovich

Fix fallback float formatter at assymetric bounds (#1976)

parent 5f7f7b95
...@@ -2337,7 +2337,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer<char>& buf, ...@@ -2337,7 +2337,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer<char>& buf,
upper = &upper_store; upper = &upper_store;
} }
denominator.assign_pow10(exp10); denominator.assign_pow10(exp10);
denominator <<= 1; denominator <<= shift;
} else if (exp10 < 0) { } else if (exp10 < 0) {
numerator.assign_pow10(-exp10); numerator.assign_pow10(-exp10);
lower.assign(numerator); lower.assign(numerator);
......
...@@ -1270,6 +1270,8 @@ TEST(FormatterTest, FormatDouble) { ...@@ -1270,6 +1270,8 @@ TEST(FormatterTest, FormatDouble) {
EXPECT_EQ(buffer, format("{:a}", -42.0)); EXPECT_EQ(buffer, format("{:a}", -42.0));
safe_sprintf(buffer, "%A", -42.0); safe_sprintf(buffer, "%A", -42.0);
EXPECT_EQ(buffer, format("{:A}", -42.0)); EXPECT_EQ(buffer, format("{:A}", -42.0));
EXPECT_EQ("9223372036854775808.000000",
format("{:f}", 9223372036854775807.0));
} }
TEST(FormatterTest, PrecisionRounding) { TEST(FormatterTest, PrecisionRounding) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment