mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-21 11:11:42 +00:00
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:
parent
5078f84c82
commit
cdd93d8c35
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user