1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Fix two APFloat bugs in converting hexadecimal constants.

llvm-svn: 79540
This commit is contained in:
Daniel Dunbar 2009-08-20 17:12:33 +00:00
parent 6ec8176e22
commit 9ad4b47cec
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());
}