[llvm] 0b336b6 - [APFloat] Add support for operations on Signaling NaN
Ehud Katz via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 11:03:25 PST 2020
Author: Ehud Katz
Date: 2020-01-21T21:02:00+02:00
New Revision: 0b336b6048aed922874b5d711cd0dce1e3f0aa60
URL: https://github.com/llvm/llvm-project/commit/0b336b6048aed922874b5d711cd0dce1e3f0aa60
DIFF: https://github.com/llvm/llvm-project/commit/0b336b6048aed922874b5d711cd0dce1e3f0aa60.diff
LOG: [APFloat] Add support for operations on Signaling NaN
Fix PR30781
Differential Revision: https://reviews.llvm.org/D69774
Added:
Modified:
llvm/lib/Support/APFloat.cpp
llvm/unittests/ADT/APFloatTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 37392e9f9df4..03f0bb1f705e 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -1439,25 +1439,26 @@ IEEEFloat::opStatus IEEEFloat::addOrSubtractSpecials(const IEEEFloat &rhs,
default:
llvm_unreachable(nullptr);
+ case PackCategoriesIntoKey(fcZero, fcNaN):
+ case PackCategoriesIntoKey(fcNormal, fcNaN):
+ case PackCategoriesIntoKey(fcInfinity, fcNaN):
+ assign(rhs);
+ LLVM_FALLTHROUGH;
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
case PackCategoriesIntoKey(fcNaN, fcInfinity):
case PackCategoriesIntoKey(fcNaN, fcNaN):
+ if (isSignaling()) {
+ makeQuiet();
+ return opInvalidOp;
+ }
+ return rhs.isSignaling() ? opInvalidOp : opOK;
+
case PackCategoriesIntoKey(fcNormal, fcZero):
case PackCategoriesIntoKey(fcInfinity, fcNormal):
case PackCategoriesIntoKey(fcInfinity, fcZero):
return opOK;
- case PackCategoriesIntoKey(fcZero, fcNaN):
- case PackCategoriesIntoKey(fcNormal, fcNaN):
- case PackCategoriesIntoKey(fcInfinity, fcNaN):
- // We need to be sure to flip the sign here for subtraction because we
- // don't have a separate negate operation so -NaN becomes 0 - NaN here.
- sign = rhs.sign ^ subtract;
- category = fcNaN;
- copySignificand(rhs);
- return opOK;
-
case PackCategoriesIntoKey(fcNormal, fcInfinity):
case PackCategoriesIntoKey(fcZero, fcInfinity):
category = fcInfinity;
@@ -1562,20 +1563,22 @@ IEEEFloat::opStatus IEEEFloat::multiplySpecials(const IEEEFloat &rhs) {
default:
llvm_unreachable(nullptr);
- case PackCategoriesIntoKey(fcNaN, fcZero):
- case PackCategoriesIntoKey(fcNaN, fcNormal):
- case PackCategoriesIntoKey(fcNaN, fcInfinity):
- case PackCategoriesIntoKey(fcNaN, fcNaN):
- sign = false;
- return opOK;
-
case PackCategoriesIntoKey(fcZero, fcNaN):
case PackCategoriesIntoKey(fcNormal, fcNaN):
case PackCategoriesIntoKey(fcInfinity, fcNaN):
+ assign(rhs);
sign = false;
- category = fcNaN;
- copySignificand(rhs);
- return opOK;
+ LLVM_FALLTHROUGH;
+ case PackCategoriesIntoKey(fcNaN, fcZero):
+ case PackCategoriesIntoKey(fcNaN, fcNormal):
+ case PackCategoriesIntoKey(fcNaN, fcInfinity):
+ case PackCategoriesIntoKey(fcNaN, fcNaN):
+ sign ^= rhs.sign; // restore the original sign
+ if (isSignaling()) {
+ makeQuiet();
+ return opInvalidOp;
+ }
+ return rhs.isSignaling() ? opInvalidOp : opOK;
case PackCategoriesIntoKey(fcNormal, fcInfinity):
case PackCategoriesIntoKey(fcInfinity, fcNormal):
@@ -1607,15 +1610,20 @@ IEEEFloat::opStatus IEEEFloat::divideSpecials(const IEEEFloat &rhs) {
case PackCategoriesIntoKey(fcZero, fcNaN):
case PackCategoriesIntoKey(fcNormal, fcNaN):
case PackCategoriesIntoKey(fcInfinity, fcNaN):
- category = fcNaN;
- copySignificand(rhs);
+ assign(rhs);
+ sign = false;
LLVM_FALLTHROUGH;
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
case PackCategoriesIntoKey(fcNaN, fcInfinity):
case PackCategoriesIntoKey(fcNaN, fcNaN):
- sign = false;
- LLVM_FALLTHROUGH;
+ sign ^= rhs.sign; // restore the original sign
+ if (isSignaling()) {
+ makeQuiet();
+ return opInvalidOp;
+ }
+ return rhs.isSignaling() ? opInvalidOp : opOK;
+
case PackCategoriesIntoKey(fcInfinity, fcZero):
case PackCategoriesIntoKey(fcInfinity, fcNormal):
case PackCategoriesIntoKey(fcZero, fcInfinity):
@@ -1645,23 +1653,26 @@ IEEEFloat::opStatus IEEEFloat::modSpecials(const IEEEFloat &rhs) {
default:
llvm_unreachable(nullptr);
+ case PackCategoriesIntoKey(fcZero, fcNaN):
+ case PackCategoriesIntoKey(fcNormal, fcNaN):
+ case PackCategoriesIntoKey(fcInfinity, fcNaN):
+ assign(rhs);
+ LLVM_FALLTHROUGH;
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
case PackCategoriesIntoKey(fcNaN, fcInfinity):
case PackCategoriesIntoKey(fcNaN, fcNaN):
+ if (isSignaling()) {
+ makeQuiet();
+ return opInvalidOp;
+ }
+ return rhs.isSignaling() ? opInvalidOp : opOK;
+
case PackCategoriesIntoKey(fcZero, fcInfinity):
case PackCategoriesIntoKey(fcZero, fcNormal):
case PackCategoriesIntoKey(fcNormal, fcInfinity):
return opOK;
- case PackCategoriesIntoKey(fcZero, fcNaN):
- case PackCategoriesIntoKey(fcNormal, fcNaN):
- case PackCategoriesIntoKey(fcInfinity, fcNaN):
- sign = false;
- category = fcNaN;
- copySignificand(rhs);
- return opOK;
-
case PackCategoriesIntoKey(fcNormal, fcZero):
case PackCategoriesIntoKey(fcInfinity, fcZero):
case PackCategoriesIntoKey(fcInfinity, fcNormal):
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index c50202b7ddef..812e657dc74f 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -1859,17 +1859,12 @@ TEST(APFloatTest, isFiniteNonZero) {
TEST(APFloatTest, add) {
// Test Special Cases against each other and normal values.
- // TODOS/NOTES:
- // 1. Since we perform only default exception handling all operations with
- // signaling NaNs should have a result that is a quiet NaN. Currently they
- // return sNaN.
-
APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false);
APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true);
APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false);
APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true);
APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false);
- APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false);
+ APFloat SNaN = APFloat(APFloat::IEEEsingle(), "snan123");
APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0");
APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0");
APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false);
@@ -1883,23 +1878,19 @@ TEST(APFloatTest, add) {
const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact;
- const unsigned NumTests = 169;
struct {
APFloat x;
APFloat y;
const char *result;
int status;
int category;
- } SpecialCaseTests[NumTests] = {
+ } SpecialCaseTests[] = {
{ PInf, PInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, PZero, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MZero, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { PInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, PNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, PLargestValue, "inf", APFloat::opOK, APFloat::fcInfinity },
@@ -1913,10 +1904,7 @@ TEST(APFloatTest, add) {
{ MInf, PZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, PNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, PLargestValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
@@ -1930,10 +1918,7 @@ TEST(APFloatTest, add) {
{ PZero, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { PZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, PNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PZero, MNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PZero, PLargestValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -1947,10 +1932,7 @@ TEST(APFloatTest, add) {
{ MZero, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, PNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MZero, MNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MZero, PLargestValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -1964,10 +1946,7 @@ TEST(APFloatTest, add) {
{ QNaN, PZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
{ QNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
{ QNaN, PNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PLargestValue, "nan", APFloat::opOK, APFloat::fcNaN },
@@ -1976,32 +1955,26 @@ TEST(APFloatTest, add) {
{ QNaN, MSmallestValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { SNaN, PInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, QNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { SNaN, PInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, QNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, MInf, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, PZero, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, MZero, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { PNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PNormalValue, "0x1p+1", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, MNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2015,10 +1988,7 @@ TEST(APFloatTest, add) {
{ MNormalValue, PZero, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, MZero, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MNormalValue, PNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MNormalValue, MNormalValue, "-0x1p+1", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2032,10 +2002,7 @@ TEST(APFloatTest, add) {
{ PLargestValue, PZero, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, MZero, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { PLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PLargestValue, PNormalValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ PLargestValue, MNormalValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ PLargestValue, PLargestValue, "inf", OverflowStatus, APFloat::fcInfinity },
@@ -2049,10 +2016,7 @@ TEST(APFloatTest, add) {
{ MLargestValue, PZero, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, MZero, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MLargestValue, PNormalValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ MLargestValue, MNormalValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ MLargestValue, PLargestValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2066,10 +2030,7 @@ TEST(APFloatTest, add) {
{ PSmallestValue, PZero, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, MZero, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { PSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestValue, PNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestValue, MNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestValue, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2083,10 +2044,7 @@ TEST(APFloatTest, add) {
{ MSmallestValue, PZero, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, MZero, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestValue, PNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestValue, MNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestValue, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2100,10 +2058,7 @@ TEST(APFloatTest, add) {
{ PSmallestNormalized, PZero, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, MZero, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestNormalized, PNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestNormalized, MNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestNormalized, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2117,10 +2072,7 @@ TEST(APFloatTest, add) {
{ MSmallestNormalized, PZero, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, MZero, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
- // See Note 1.
- { MSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestNormalized, PNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestNormalized, MNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestNormalized, PLargestValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2131,7 +2083,7 @@ TEST(APFloatTest, add) {
{ MSmallestNormalized, MSmallestNormalized, "-0x1p-125", APFloat::opOK, APFloat::fcNormal }
};
- for (size_t i = 0; i < NumTests; ++i) {
+ for (size_t i = 0; i < array_lengthof(SpecialCaseTests); ++i) {
APFloat x(SpecialCaseTests[i].x);
APFloat y(SpecialCaseTests[i].y);
APFloat::opStatus status = x.add(y, APFloat::rmNearestTiesToEven);
@@ -2139,25 +2091,20 @@ TEST(APFloatTest, add) {
APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result);
EXPECT_TRUE(result.bitwiseIsEqual(x));
- EXPECT_TRUE((int)status == SpecialCaseTests[i].status);
- EXPECT_TRUE((int)x.getCategory() == SpecialCaseTests[i].category);
+ EXPECT_EQ(SpecialCaseTests[i].status, (int)status);
+ EXPECT_EQ(SpecialCaseTests[i].category, (int)x.getCategory());
}
}
TEST(APFloatTest, subtract) {
// Test Special Cases against each other and normal values.
- // TODOS/NOTES:
- // 1. Since we perform only default exception handling all operations with
- // signaling NaNs should have a result that is a quiet NaN. Currently they
- // return sNaN.
-
APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false);
APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true);
APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false);
APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true);
APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false);
- APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false);
+ APFloat SNaN = APFloat(APFloat::IEEEsingle(), "snan123");
APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0");
APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0");
APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false);
@@ -2171,23 +2118,19 @@ TEST(APFloatTest, subtract) {
const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact;
- const unsigned NumTests = 169;
struct {
APFloat x;
APFloat y;
const char *result;
int status;
int category;
- } SpecialCaseTests[NumTests] = {
+ } SpecialCaseTests[] = {
{ PInf, PInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, PZero, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MZero, "inf", APFloat::opOK, APFloat::fcInfinity },
- { PInf, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PInf, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, PNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, PLargestValue, "inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2200,11 +2143,8 @@ TEST(APFloatTest, subtract) {
{ MInf, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, PZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
- { MInf, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MInf, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, PNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, PLargestValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2217,11 +2157,8 @@ TEST(APFloatTest, subtract) {
{ PZero, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PZero, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
- { PZero, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PZero, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, PNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PZero, MNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PZero, PLargestValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -2234,11 +2171,8 @@ TEST(APFloatTest, subtract) {
{ MZero, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MZero, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
- { MZero, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MZero, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, PNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MZero, MNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MZero, PLargestValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -2252,10 +2186,7 @@ TEST(APFloatTest, subtract) {
{ QNaN, PZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
{ QNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
{ QNaN, PNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PLargestValue, "nan", APFloat::opOK, APFloat::fcNaN },
@@ -2264,32 +2195,26 @@ TEST(APFloatTest, subtract) {
{ QNaN, MSmallestValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { SNaN, PInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, QNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { SNaN, PInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, QNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PInf, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, PZero, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, MZero, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
- { PNormalValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PNormalValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, MNormalValue, "0x1p+1", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2302,11 +2227,8 @@ TEST(APFloatTest, subtract) {
{ MNormalValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MNormalValue, PZero, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, MZero, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
- { MNormalValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MNormalValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MNormalValue, PNormalValue, "-0x1p+1", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, MNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MNormalValue, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2319,11 +2241,8 @@ TEST(APFloatTest, subtract) {
{ PLargestValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PLargestValue, PZero, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, MZero, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
- { PLargestValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PLargestValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PLargestValue, PNormalValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ PLargestValue, MNormalValue, "0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ PLargestValue, PLargestValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2336,11 +2255,8 @@ TEST(APFloatTest, subtract) {
{ MLargestValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MLargestValue, PZero, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, MZero, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
- { MLargestValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MLargestValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MLargestValue, PNormalValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ MLargestValue, MNormalValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
{ MLargestValue, PLargestValue, "-inf", OverflowStatus, APFloat::fcInfinity },
@@ -2353,11 +2269,8 @@ TEST(APFloatTest, subtract) {
{ PSmallestValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PSmallestValue, PZero, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, MZero, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
- { PSmallestValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestValue, PNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestValue, MNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestValue, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2370,11 +2283,8 @@ TEST(APFloatTest, subtract) {
{ MSmallestValue, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MSmallestValue, PZero, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, MZero, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
- { MSmallestValue, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestValue, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestValue, PNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestValue, MNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestValue, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2387,11 +2297,8 @@ TEST(APFloatTest, subtract) {
{ PSmallestNormalized, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PSmallestNormalized, PZero, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, MZero, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
- { PSmallestNormalized, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestNormalized, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { PSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestNormalized, PNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestNormalized, MNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ PSmallestNormalized, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2404,11 +2311,8 @@ TEST(APFloatTest, subtract) {
{ MSmallestNormalized, MInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MSmallestNormalized, PZero, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, MZero, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
- { MSmallestNormalized, QNaN, "-nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestNormalized, SNaN, "-nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
+ { MSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestNormalized, PNormalValue, "-0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestNormalized, MNormalValue, "0x1p+0", APFloat::opInexact, APFloat::fcNormal },
{ MSmallestNormalized, PLargestValue, "-0x1.fffffep+127", APFloat::opInexact, APFloat::fcNormal },
@@ -2419,7 +2323,7 @@ TEST(APFloatTest, subtract) {
{ MSmallestNormalized, MSmallestNormalized, "0x0p+0", APFloat::opOK, APFloat::fcZero }
};
- for (size_t i = 0; i < NumTests; ++i) {
+ for (size_t i = 0; i < array_lengthof(SpecialCaseTests); ++i) {
APFloat x(SpecialCaseTests[i].x);
APFloat y(SpecialCaseTests[i].y);
APFloat::opStatus status = x.subtract(y, APFloat::rmNearestTiesToEven);
@@ -2427,25 +2331,20 @@ TEST(APFloatTest, subtract) {
APFloat result(APFloat::IEEEsingle(), SpecialCaseTests[i].result);
EXPECT_TRUE(result.bitwiseIsEqual(x));
- EXPECT_TRUE((int)status == SpecialCaseTests[i].status);
- EXPECT_TRUE((int)x.getCategory() == SpecialCaseTests[i].category);
+ EXPECT_EQ(SpecialCaseTests[i].status, (int)status);
+ EXPECT_EQ(SpecialCaseTests[i].category, (int)x.getCategory());
}
}
TEST(APFloatTest, multiply) {
// Test Special Cases against each other and normal values.
- // TODOS/NOTES:
- // 1. Since we perform only default exception handling all operations with
- // signaling NaNs should have a result that is a quiet NaN. Currently they
- // return sNaN.
-
APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false);
APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true);
APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false);
APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true);
APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false);
- APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false);
+ APFloat SNaN = APFloat(APFloat::IEEEsingle(), "snan123");
APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0");
APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0");
APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false);
@@ -2480,10 +2379,7 @@ TEST(APFloatTest, multiply) {
{ PInf, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, PNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, PLargestValue, "inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2497,10 +2393,7 @@ TEST(APFloatTest, multiply) {
{ MInf, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, PNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, PLargestValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2514,10 +2407,7 @@ TEST(APFloatTest, multiply) {
{ PZero, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, PNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, MNormalValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, PLargestValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2531,10 +2421,7 @@ TEST(APFloatTest, multiply) {
{ MZero, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, PNormalValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, MNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, PLargestValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2548,10 +2435,7 @@ TEST(APFloatTest, multiply) {
{ QNaN, PZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
{ QNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
{ QNaN, PNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PLargestValue, "nan", APFloat::opOK, APFloat::fcNaN },
@@ -2560,32 +2444,26 @@ TEST(APFloatTest, multiply) {
{ QNaN, MSmallestValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { SNaN, PInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, QNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { SNaN, PInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, QNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PInf, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, MInf, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PNormalValue, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, MNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, PLargestValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -2599,10 +2477,7 @@ TEST(APFloatTest, multiply) {
{ MNormalValue, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MNormalValue, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MNormalValue, PNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, MNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, PLargestValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
@@ -2616,10 +2491,7 @@ TEST(APFloatTest, multiply) {
{ PLargestValue, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PLargestValue, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PLargestValue, PNormalValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, MNormalValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, PLargestValue, "inf", OverflowStatus, APFloat::fcInfinity },
@@ -2633,10 +2505,7 @@ TEST(APFloatTest, multiply) {
{ MLargestValue, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MLargestValue, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MLargestValue, PNormalValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, MNormalValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, PLargestValue, "-inf", OverflowStatus, APFloat::fcInfinity },
@@ -2650,10 +2519,7 @@ TEST(APFloatTest, multiply) {
{ PSmallestValue, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PSmallestValue, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestValue, PNormalValue, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, MNormalValue, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, PLargestValue, "0x1.fffffep-22", APFloat::opOK, APFloat::fcNormal },
@@ -2667,10 +2533,7 @@ TEST(APFloatTest, multiply) {
{ MSmallestValue, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MSmallestValue, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestValue, PNormalValue, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, MNormalValue, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, PLargestValue, "-0x1.fffffep-22", APFloat::opOK, APFloat::fcNormal },
@@ -2684,10 +2547,7 @@ TEST(APFloatTest, multiply) {
{ PSmallestNormalized, PZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PSmallestNormalized, MZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestNormalized, PNormalValue, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, MNormalValue, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, PLargestValue, "0x1.fffffep+1", APFloat::opOK, APFloat::fcNormal },
@@ -2701,10 +2561,7 @@ TEST(APFloatTest, multiply) {
{ MSmallestNormalized, PZero, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MSmallestNormalized, MZero, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestNormalized, PNormalValue, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, MNormalValue, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, PLargestValue, "-0x1.fffffep+1", APFloat::opOK, APFloat::fcNormal },
@@ -2778,25 +2635,20 @@ TEST(APFloatTest, multiply) {
APFloat result(x.getSemantics(), SpecialCaseTests[i].result);
EXPECT_TRUE(result.bitwiseIsEqual(x));
- EXPECT_TRUE((int)status == SpecialCaseTests[i].status);
- EXPECT_TRUE((int)x.getCategory() == SpecialCaseTests[i].category);
+ EXPECT_EQ(SpecialCaseTests[i].status, (int)status);
+ EXPECT_EQ(SpecialCaseTests[i].category, (int)x.getCategory());
}
}
TEST(APFloatTest, divide) {
// Test Special Cases against each other and normal values.
- // TODOS/NOTES:
- // 1. Since we perform only default exception handling all operations with
- // signaling NaNs should have a result that is a quiet NaN. Currently they
- // return sNaN.
-
APFloat PInf = APFloat::getInf(APFloat::IEEEsingle(), false);
APFloat MInf = APFloat::getInf(APFloat::IEEEsingle(), true);
APFloat PZero = APFloat::getZero(APFloat::IEEEsingle(), false);
APFloat MZero = APFloat::getZero(APFloat::IEEEsingle(), true);
APFloat QNaN = APFloat::getNaN(APFloat::IEEEsingle(), false);
- APFloat SNaN = APFloat::getSNaN(APFloat::IEEEsingle(), false);
+ APFloat SNaN = APFloat(APFloat::IEEEsingle(), "snan123");
APFloat PNormalValue = APFloat(APFloat::IEEEsingle(), "0x1p+0");
APFloat MNormalValue = APFloat(APFloat::IEEEsingle(), "-0x1p+0");
APFloat PLargestValue = APFloat::getLargest(APFloat::IEEEsingle(), false);
@@ -2831,10 +2683,7 @@ TEST(APFloatTest, divide) {
{ PInf, PZero, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PInf, PNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, MNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ PInf, PLargestValue, "inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2848,10 +2697,7 @@ TEST(APFloatTest, divide) {
{ MInf, PZero, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MZero, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MInf, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MInf, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MInf, PNormalValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, MNormalValue, "inf", APFloat::opOK, APFloat::fcInfinity },
{ MInf, PLargestValue, "-inf", APFloat::opOK, APFloat::fcInfinity },
@@ -2865,10 +2711,7 @@ TEST(APFloatTest, divide) {
{ PZero, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PZero, PNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, MNormalValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PZero, PLargestValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2882,10 +2725,7 @@ TEST(APFloatTest, divide) {
{ MZero, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MZero, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MZero, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MZero, PNormalValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, MNormalValue, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ MZero, PLargestValue, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
@@ -2899,10 +2739,7 @@ TEST(APFloatTest, divide) {
{ QNaN, PZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MZero, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
{ QNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
{ QNaN, PNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MNormalValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PLargestValue, "nan", APFloat::opOK, APFloat::fcNaN },
@@ -2911,32 +2748,26 @@ TEST(APFloatTest, divide) {
{ QNaN, MSmallestValue, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, PSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
{ QNaN, MSmallestNormalized, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { SNaN, PInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MInf, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MZero, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, QNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MNormalValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MLargestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestValue, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, PSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
- { SNaN, MSmallestNormalized, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { SNaN, PInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MInf, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MZero, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, QNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MNormalValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MLargestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestValue, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, PSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
+ { SNaN, MSmallestNormalized, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PInf, "0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, MInf, "-0x0p+0", APFloat::opOK, APFloat::fcZero },
{ PNormalValue, PZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PNormalValue, MZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PNormalValue, PNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, MNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ PNormalValue, PLargestValue, "0x1p-128", UnderflowStatus, APFloat::fcNormal },
@@ -2950,10 +2781,7 @@ TEST(APFloatTest, divide) {
{ MNormalValue, PZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MNormalValue, MZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MNormalValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MNormalValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MNormalValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MNormalValue, PNormalValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, MNormalValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
{ MNormalValue, PLargestValue, "-0x1p-128", UnderflowStatus, APFloat::fcNormal },
@@ -2967,10 +2795,7 @@ TEST(APFloatTest, divide) {
{ PLargestValue, PZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PLargestValue, MZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PLargestValue, PNormalValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, MNormalValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ PLargestValue, PLargestValue, "0x1p+0", APFloat::opOK, APFloat::fcNormal },
@@ -2984,10 +2809,7 @@ TEST(APFloatTest, divide) {
{ MLargestValue, PZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MLargestValue, MZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MLargestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MLargestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MLargestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MLargestValue, PNormalValue, "-0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, MNormalValue, "0x1.fffffep+127", APFloat::opOK, APFloat::fcNormal },
{ MLargestValue, PLargestValue, "-0x1p+0", APFloat::opOK, APFloat::fcNormal },
@@ -3001,10 +2823,7 @@ TEST(APFloatTest, divide) {
{ PSmallestValue, PZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PSmallestValue, MZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestValue, PNormalValue, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, MNormalValue, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ PSmallestValue, PLargestValue, "0x0p+0", UnderflowStatus, APFloat::fcZero },
@@ -3018,10 +2837,7 @@ TEST(APFloatTest, divide) {
{ MSmallestValue, PZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MSmallestValue, MZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MSmallestValue, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestValue, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestValue, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestValue, PNormalValue, "-0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, MNormalValue, "0x1p-149", APFloat::opOK, APFloat::fcNormal },
{ MSmallestValue, PLargestValue, "-0x0p+0", UnderflowStatus, APFloat::fcZero },
@@ -3035,10 +2851,7 @@ TEST(APFloatTest, divide) {
{ PSmallestNormalized, PZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PSmallestNormalized, MZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ PSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { PSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { PSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ PSmallestNormalized, PNormalValue, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, MNormalValue, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ PSmallestNormalized, PLargestValue, "0x0p+0", UnderflowStatus, APFloat::fcZero },
@@ -3052,10 +2865,7 @@ TEST(APFloatTest, divide) {
{ MSmallestNormalized, PZero, "-inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MSmallestNormalized, MZero, "inf", APFloat::opDivByZero, APFloat::fcInfinity },
{ MSmallestNormalized, QNaN, "nan", APFloat::opOK, APFloat::fcNaN },
-#if 0
-// See Note 1.
- { MSmallestNormalized, SNaN, "nan", APFloat::opInvalidOp, APFloat::fcNaN },
-#endif
+ { MSmallestNormalized, SNaN, "nan123", APFloat::opInvalidOp, APFloat::fcNaN },
{ MSmallestNormalized, PNormalValue, "-0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, MNormalValue, "0x1p-126", APFloat::opOK, APFloat::fcNormal },
{ MSmallestNormalized, PLargestValue, "-0x0p+0", UnderflowStatus, APFloat::fcZero },
@@ -3107,8 +2917,8 @@ TEST(APFloatTest, divide) {
APFloat result(x.getSemantics(), SpecialCaseTests[i].result);
EXPECT_TRUE(result.bitwiseIsEqual(x));
- EXPECT_TRUE((int)status == SpecialCaseTests[i].status);
- EXPECT_TRUE((int)x.getCategory() == SpecialCaseTests[i].category);
+ EXPECT_EQ(SpecialCaseTests[i].status, (int)status);
+ EXPECT_EQ(SpecialCaseTests[i].category, (int)x.getCategory());
}
}
More information about the llvm-commits
mailing list