Commit aab900fd authored by floitschV8@gmail.com's avatar floitschV8@gmail.com

Fix Double.NextDouble function.

This unbreaks the build on windows.

TBR: whesse@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/4681001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5779 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 808d00f8
......@@ -83,8 +83,16 @@ class Double {
}
double NextDouble() const {
if (d64_ == kInfinity) return kInfinity;
return Double(d64_ + 1).value();
if (d64_ == kInfinity) return Double(kInfinity).value();
if (Sign() < 0 && Significand() == 0) {
// -0.0
return 0.0;
}
if (Sign() < 0) {
return Double(d64_ - 1).value();
} else {
return Double(d64_ + 1).value();
}
}
int Exponent() const {
......
......@@ -202,3 +202,19 @@ TEST(NormalizedBoundaries) {
CHECK(diy_fp.f() - boundary_minus.f() == boundary_plus.f() - diy_fp.f());
CHECK((1 << 10) == diy_fp.f() - boundary_minus.f()); // NOLINT
}
TEST(NextDouble) {
CHECK_EQ(4e-324, Double(0.0).NextDouble());
CHECK_EQ(0.0, Double(-0.0).NextDouble());
CHECK_EQ(-0.0, Double(-4e-324).NextDouble());
Double d0(-4e-324);
Double d1(d0.NextDouble());
Double d2(d1.NextDouble());
CHECK_EQ(-0.0, d1.value());
CHECK_EQ(0.0, d2.value());
CHECK_EQ(4e-324, d2.NextDouble());
CHECK_EQ(-1.7976931348623157e308, Double(-V8_INFINITY).NextDouble());
CHECK_EQ(V8_INFINITY,
Double(V8_2PART_UINT64_C(0x7fefffff, ffffffff)).NextDouble());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment