Revision: 5779
Author: [email protected]
Date: Mon Nov  8 04:13:05 2010
Log: Fix Double.NextDouble function.

This unbreaks the build on windows.

TBR: [email protected]
BUG=
TEST=

Review URL: http://codereview.chromium.org/4681001
http://code.google.com/p/v8/source/detail?r=5779

Modified:
 /branches/bleeding_edge/src/double.h
 /branches/bleeding_edge/test/cctest/test-double.cc

=======================================
--- /branches/bleeding_edge/src/double.h        Mon Nov  8 03:49:47 2010
+++ /branches/bleeding_edge/src/double.h        Mon Nov  8 04:13:05 2010
@@ -83,8 +83,16 @@
   }

   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 {
=======================================
--- /branches/bleeding_edge/test/cctest/test-double.cc Fri Mar 19 05:15:24 2010 +++ /branches/bleeding_edge/test/cctest/test-double.cc Mon Nov 8 04:13:05 2010
@@ -202,3 +202,19 @@
   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());
+}

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to