mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[APFloat] Overload unary operator-
Summary: We already have overloaded binary arithemetic operators so you can write A+B etc. This patch lets you write -A instead of neg(A). Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75236
This commit is contained in:
parent
39d6261f16
commit
7fd61457ea
@ -1036,6 +1036,13 @@ public:
|
||||
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 {
|
||||
|
@ -2990,6 +2990,17 @@ TEST(APFloatTest, neg) {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user