Print the sign of negative infinity

Differential Revision: https://reviews.llvm.org/D111917
This commit is contained in:
Logan Chien 2021-10-15 17:43:25 -07:00
parent 4cd6dc5adb
commit 9eb71608ee
2 changed files with 3 additions and 1 deletions

View File

@ -168,7 +168,7 @@ void llvm::write_double(raw_ostream &S, double N, FloatStyle Style,
S << "nan";
return;
} else if (std::isinf(N)) {
S << "INF";
S << (std::signbit(N) ? "-INF" : "INF");
return;
}

View File

@ -125,6 +125,8 @@ TEST(NativeFormatTest, BoundaryTests) {
FloatStyle::Fixed));
EXPECT_EQ("INF", format_number(std::numeric_limits<double>::infinity(),
FloatStyle::Fixed));
EXPECT_EQ("-INF", format_number(-std::numeric_limits<double>::infinity(),
FloatStyle::Fixed));
}
TEST(NativeFormatTest, HexTests) {