mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[APFloat] Fix IsInteger() for DoubleAPFloat.
Previously, we would just assert instead. Differential Revision: https://reviews.llvm.org/D36961 llvm-svn: 311351
This commit is contained in:
parent
6bf02fc19f
commit
8194334bae
@ -4363,10 +4363,7 @@ bool DoubleAPFloat::isLargest() const {
|
||||
|
||||
bool DoubleAPFloat::isInteger() const {
|
||||
assert(Semantics == &semPPCDoubleDouble && "Unexpected Semantics");
|
||||
APFloat Tmp(semPPCDoubleDoubleLegacy);
|
||||
(void)Tmp.add(Floats[0], rmNearestTiesToEven);
|
||||
(void)Tmp.add(Floats[1], rmNearestTiesToEven);
|
||||
return Tmp.isInteger();
|
||||
return Floats[0].isInteger() && Floats[1].isInteger();
|
||||
}
|
||||
|
||||
void DoubleAPFloat::toString(SmallVectorImpl<char> &Str,
|
||||
|
@ -1349,6 +1349,24 @@ TEST(APFloatTest, isInteger) {
|
||||
EXPECT_TRUE(T.isInteger());
|
||||
}
|
||||
|
||||
TEST(DoubleAPFloatTest, isInteger) {
|
||||
APFloat F1(-0.0);
|
||||
APFloat F2(-0.0);
|
||||
llvm::detail::DoubleAPFloat T(APFloat::PPCDoubleDouble(), std::move(F1),
|
||||
std::move(F2));
|
||||
EXPECT_TRUE(T.isInteger());
|
||||
APFloat F3(3.14159);
|
||||
APFloat F4(-0.0);
|
||||
llvm::detail::DoubleAPFloat T2(APFloat::PPCDoubleDouble(), std::move(F3),
|
||||
std::move(F4));
|
||||
EXPECT_FALSE(T2.isInteger());
|
||||
APFloat F5(-0.0);
|
||||
APFloat F6(3.14159);
|
||||
llvm::detail::DoubleAPFloat T3(APFloat::PPCDoubleDouble(), std::move(F5),
|
||||
std::move(F6));
|
||||
EXPECT_FALSE(T3.isInteger());
|
||||
}
|
||||
|
||||
TEST(APFloatTest, getLargest) {
|
||||
EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle()).convertToFloat());
|
||||
EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble()).convertToDouble());
|
||||
|
Loading…
Reference in New Issue
Block a user