Index: llvm/lib/Support/APFloat.cpp =================================================================== --- llvm/lib/Support/APFloat.cpp +++ llvm/lib/Support/APFloat.cpp @@ -1432,25 +1432,26 @@ 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; @@ -1558,20 +1559,22 @@ 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): @@ -1603,15 +1606,20 @@ 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): @@ -1641,23 +1649,26 @@ 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): Index: llvm/unittests/ADT/APFloatTest.cpp =================================================================== --- llvm/unittests/ADT/APFloatTest.cpp +++ llvm/unittests/ADT/APFloatTest.cpp @@ -1740,17 +1740,12 @@ 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); @@ -1764,23 +1759,19 @@ 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 }, @@ -1794,10 +1785,7 @@ { 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 }, @@ -1811,10 +1799,7 @@ { 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 }, @@ -1828,10 +1813,7 @@ { 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 }, @@ -1845,10 +1827,7 @@ { 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 }, @@ -1857,32 +1836,26 @@ { 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 }, @@ -1896,10 +1869,7 @@ { 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 }, @@ -1913,10 +1883,7 @@ { 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 }, @@ -1930,10 +1897,7 @@ { 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 }, @@ -1947,10 +1911,7 @@ { 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 }, @@ -1964,10 +1925,7 @@ { 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 }, @@ -1981,10 +1939,7 @@ { 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 }, @@ -1998,10 +1953,7 @@ { 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 }, @@ -2012,7 +1964,7 @@ { 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); @@ -2020,25 +1972,20 @@ 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); @@ -2052,23 +1999,19 @@ 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 }, @@ -2081,11 +2024,8 @@ { 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 }, @@ -2098,11 +2038,8 @@ { 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 }, @@ -2115,11 +2052,8 @@ { 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 }, @@ -2133,10 +2067,7 @@ { 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 }, @@ -2145,32 +2076,26 @@ { 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 }, @@ -2183,11 +2108,8 @@ { 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 }, @@ -2200,11 +2122,8 @@ { 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 }, @@ -2217,11 +2136,8 @@ { 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 }, @@ -2234,11 +2150,8 @@ { 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 }, @@ -2251,11 +2164,8 @@ { 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 }, @@ -2268,11 +2178,8 @@ { 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 }, @@ -2285,11 +2192,8 @@ { 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 }, @@ -2300,7 +2204,7 @@ { 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); @@ -2308,25 +2212,20 @@ 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); @@ -2341,23 +2240,19 @@ const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; const int UnderflowStatus = APFloat::opUnderflow | 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, "-inf", APFloat::opOK, APFloat::fcInfinity }, { 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 }, @@ -2371,10 +2266,7 @@ { 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 }, @@ -2388,10 +2280,7 @@ { 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 }, @@ -2405,10 +2294,7 @@ { 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 }, @@ -2422,10 +2308,7 @@ { 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 }, @@ -2434,32 +2317,26 @@ { 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 }, @@ -2473,10 +2350,7 @@ { 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 }, @@ -2490,10 +2364,7 @@ { 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 }, @@ -2507,10 +2378,7 @@ { 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 }, @@ -2524,10 +2392,7 @@ { 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 }, @@ -2541,10 +2406,7 @@ { 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 }, @@ -2558,10 +2420,7 @@ { 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 }, @@ -2575,10 +2434,7 @@ { 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 }, @@ -2589,7 +2445,7 @@ { MSmallestNormalized, MSmallestNormalized, "0x0p+0", UnderflowStatus, 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.multiply(y, APFloat::rmNearestTiesToEven); @@ -2597,25 +2453,20 @@ 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, 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); @@ -2630,23 +2481,19 @@ const int OverflowStatus = APFloat::opOverflow | APFloat::opInexact; const int UnderflowStatus = APFloat::opUnderflow | 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, "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 }, @@ -2660,10 +2507,7 @@ { 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 }, @@ -2677,10 +2521,7 @@ { 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 }, @@ -2694,10 +2535,7 @@ { 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 }, @@ -2711,10 +2549,7 @@ { 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 }, @@ -2723,32 +2558,26 @@ { 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 }, @@ -2762,10 +2591,7 @@ { 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 }, @@ -2779,10 +2605,7 @@ { 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 }, @@ -2796,10 +2619,7 @@ { 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 }, @@ -2813,10 +2633,7 @@ { 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 }, @@ -2830,10 +2647,7 @@ { 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 }, @@ -2847,10 +2661,7 @@ { 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 }, @@ -2864,10 +2675,7 @@ { 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 }, @@ -2878,7 +2686,7 @@ { MSmallestNormalized, MSmallestNormalized, "0x1p+0", 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.divide(y, APFloat::rmNearestTiesToEven); @@ -2886,8 +2694,8 @@ 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()); } }