llvm.org GIT mirror llvm / 7247a5f
Fix APFloat::getLargest so that it actually returns the correct value. Found by accident while reviewing a patch to nearby code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141816 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 8 years ago
2 changed file(s) with 9 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
32423242 significand[i] = ~((integerPart) 0);
32433243
32443244 // ...and then clear the top bits for internal consistency.
3245 significand[N-1] &=
3246 (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1;
3245 if (Sem.precision % integerPartWidth != 0)
3246 significand[N-1] &=
3247 (((integerPart) 1) << (Sem.precision % integerPartWidth)) - 1;
32473248
32483249 return Val;
32493250 }
647647 EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(0));
648648 }
649649
650 }
650 TEST(APFloatTest, getLargest) {
651 EXPECT_EQ(3.40282347e+38f, APFloat::getLargest(APFloat::IEEEsingle).convertToFloat());
652 EXPECT_EQ(1.7976931348623157e+308, APFloat::getLargest(APFloat::IEEEdouble).convertToDouble());
653 }
654
655 }