[PATCH] D75236: [APFloat] Overload unary operator-
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 6 01:40:12 PST 2020
This revision was automatically updated to reflect the committed changes.
foad marked an inline comment as done.
Closed by commit rG3ecfdc70cfb9: [APFloat] Overload unary operator- (authored by foad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75236/new/
https://reviews.llvm.org/D75236
Files:
llvm/include/llvm/ADT/APFloat.h
llvm/unittests/ADT/APFloatTest.cpp
Index: llvm/unittests/ADT/APFloatTest.cpp
===================================================================
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -2990,6 +2990,17 @@
EXPECT_TRUE(Inf.bitwiseIsEqual(neg(NegInf)));
EXPECT_TRUE(NegQNaN.bitwiseIsEqual(neg(QNaN)));
EXPECT_TRUE(QNaN.bitwiseIsEqual(neg(NegQNaN)));
+
+ EXPECT_TRUE(NegOne.bitwiseIsEqual(-One));
+ EXPECT_TRUE(One.bitwiseIsEqual(-NegOne));
+ EXPECT_TRUE(NegZero.bitwiseIsEqual(-Zero));
+ EXPECT_TRUE(Zero.bitwiseIsEqual(-NegZero));
+ EXPECT_TRUE(NegInf.bitwiseIsEqual(-Inf));
+ EXPECT_TRUE(Inf.bitwiseIsEqual(-NegInf));
+ EXPECT_TRUE(NegInf.bitwiseIsEqual(-Inf));
+ EXPECT_TRUE(Inf.bitwiseIsEqual(-NegInf));
+ EXPECT_TRUE(NegQNaN.bitwiseIsEqual(-QNaN));
+ EXPECT_TRUE(QNaN.bitwiseIsEqual(-NegQNaN));
}
TEST(APFloatTest, ilogb) {
Index: llvm/include/llvm/ADT/APFloat.h
===================================================================
--- llvm/include/llvm/ADT/APFloat.h
+++ llvm/include/llvm/ADT/APFloat.h
@@ -1036,6 +1036,13 @@
APFLOAT_DISPATCH_ON_SEMANTICS(next(nextDown));
}
+ /// Negate an APFloat.
+ APFloat operator-() const {
+ APFloat Result(*this);
+ Result.changeSign();
+ return Result;
+ }
+
/// Add two APFloats, rounding ties to the nearest even.
/// No error checking.
APFloat operator+(const APFloat &RHS) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75236.248664.patch
Type: text/x-patch
Size: 1389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200306/48194dfe/attachment-0001.bin>
More information about the llvm-commits
mailing list