[PATCH] D111917: Print the sign of negative infinity
Logan Chien via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 24 09:57:53 PDT 2021
Hi,
May someone please take a look?
This patch fixes a case where -inf is printed as "INF".
Thank you.
Regards,
Logan
On Fri, Oct 15, 2021 at 5:51 PM Logan Chien via Phabricator <
reviews at reviews.llvm.org> wrote:
> logan created this revision.
> Herald added subscribers: dexonsmith, hiraditya.
> logan requested review of this revision.
> Herald added a project: LLVM.
> Herald added a subscriber: llvm-commits.
>
> This commit makes `llvm::write_double` print `-inf` as `"-INF"` instead of
> `"INF"`.
>
>
> https://reviews.llvm.org/D111917
>
> Files:
> llvm/lib/Support/NativeFormatting.cpp
> llvm/unittests/Support/NativeFormatTests.cpp
>
>
> Index: llvm/unittests/Support/NativeFormatTests.cpp
> ===================================================================
> --- llvm/unittests/Support/NativeFormatTests.cpp
> +++ llvm/unittests/Support/NativeFormatTests.cpp
> @@ -125,6 +125,8 @@
> 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) {
> Index: llvm/lib/Support/NativeFormatting.cpp
> ===================================================================
> --- llvm/lib/Support/NativeFormatting.cpp
> +++ llvm/lib/Support/NativeFormatting.cpp
> @@ -168,7 +168,7 @@
> S << "nan";
> return;
> } else if (std::isinf(N)) {
> - S << "INF";
> + S << (std::signbit(N) ? "-INF" : "INF");
> return;
> }
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211024/1abd99cb/attachment.html>
More information about the llvm-commits
mailing list