Fix two APFloat bugs in converting hexadecimal constants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79540 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-08-20 17:12:33 +00:00
parent 5078f84c82
commit cdd93d8c35
2 changed files with 4 additions and 2 deletions

View File

@ -2153,7 +2153,7 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
integerPart hex_value;
if(*p == '.') {
assert(dot == 0);
assert(dot == s.end());
dot = p++;
}
@ -2190,7 +2190,7 @@ APFloat::convertFromHexadecimalString(const StringRef &s,
int expAdjustment;
/* Implicit hexadecimal point? */
if(!dot)
if (dot == s.end())
dot = p;
/* Calculate the exponent adjustment implicit in the number of

View File

@ -60,6 +60,8 @@ TEST(APFloatTest, fromString) {
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0.p1234").convertToDouble());
EXPECT_EQ(1.0625, APFloat(APFloat::IEEEdouble, "0x1.1p0").convertToDouble());
EXPECT_EQ(1.0, APFloat(APFloat::IEEEdouble, "0x1p0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, StringRef("0e1\02", 3)).convertToDouble());
}