Skip to content

Commit

Permalink
Fix hex literal bug.
Browse files Browse the repository at this point in the history
Large hex literals would lose their minus sign.
  • Loading branch information
floitsch committed Sep 9, 2018
1 parent 361924f commit bda821f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2018-09-09:
Fix bug where large hex literals would lose their minus sign.

2014-03-08:
Update version number for cmake.
Support shared libraries with cmake.
Expand Down
3 changes: 2 additions & 1 deletion src/double-conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ static double RadixStringToIeee(const char* current,
}

ASSERT(number != 0);
return Double(DiyFp(number, exponent)).value();
double result = Double(DiyFp(number, exponent)).value();
return sign ? -result : result;
}


Expand Down
37 changes: 37 additions & 0 deletions test/cctest/test-conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,43 @@ TEST(StringToDoubleHexString) {
CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);

CHECK_EQ(-5.634002666912405e+27, StrToD("-0x123456789012345678901234",
flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(72057594037927940.0, StrToD("0x100000000000001", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(72057594037927940.0, StrToD("0x100000000000000", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000001", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000000", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352900000.0, StrToD("0x100000000000008001", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000008000", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018001", flags, 0.0,
&processed, &all_used));
CHECK(all_used);

CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018000", flags, 0.0,
&processed, &all_used));
CHECK(all_used);
}


Expand Down

0 comments on commit bda821f

Please sign in to comment.