llvm.org GIT mirror llvm / 6d97003
[APFloat] Fix IsInteger() for DoubleAPFloat. Previously, we would just assert instead. Differential Revision: https://reviews.llvm.org/D36961 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311351 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 2 years ago
2 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
43624362
43634363 bool DoubleAPFloat::isInteger() const {
43644364 assert(Semantics == &semPPCDoubleDouble && "Unexpected Semantics");
4365 APFloat Tmp(semPPCDoubleDoubleLegacy);
4366 (void)Tmp.add(Floats[0], rmNearestTiesToEven);
4367 (void)Tmp.add(Floats[1], rmNearestTiesToEven);
4368 return Tmp.isInteger();
4365 return Floats[0].isInteger() && Floats[1].isInteger();
43694366 }
43704367
43714368 void DoubleAPFloat::toString(SmallVectorImpl &Str,
13461346 EXPECT_FALSE(T.isInteger());
13471347 T = APFloat::getLargest(APFloat::IEEEdouble());
13481348 EXPECT_TRUE(T.isInteger());
1349 }
1350
1351 TEST(DoubleAPFloatTest, isInteger) {
1352 APFloat F1(-0.0);
1353 APFloat F2(-0.0);
1354 llvm::detail::DoubleAPFloat T(APFloat::PPCDoubleDouble(), std::move(F1),
1355 std::move(F2));
1356 EXPECT_TRUE(T.isInteger());
1357 APFloat F3(3.14159);
1358 APFloat F4(-0.0);
1359 llvm::detail::DoubleAPFloat T2(APFloat::PPCDoubleDouble(), std::move(F3),
1360 std::move(F4));
1361 EXPECT_FALSE(T2.isInteger());
1362 APFloat F5(-0.0);
1363 APFloat F6(3.14159);
1364 llvm::detail::DoubleAPFloat T3(APFloat::PPCDoubleDouble(), std::move(F5),
1365 std::move(F6));
1366 EXPECT_FALSE(T3.isInteger());
13491367 }
13501368
13511369 TEST(APFloatTest, getLargest) {