Reviewers: William Hesse,

Description:
Add comments to double.h.

Please review this at http://codereview.chromium.org/4687001/show

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/double.h


Index: src/double.h
diff --git a/src/double.h b/src/double.h
index 54b83ecd5daf0c7371976d14340d3821945ab7c5..5c40927bc7d8697a3315d7cafdca1f5ae3c516eb 100644
--- a/src/double.h
+++ b/src/double.h
@@ -54,18 +54,20 @@ class Double {
   explicit Double(DiyFp diy_fp)
     : d64_(DiyFpToUint64(diy_fp)) {}

+  // The value encoded by this Double must be greater or equal to +0.0.
+  // It must not be special (infinity, or NaN).
   DiyFp AsDiyFp() const {
+    ASSERT(Sign() > 0);
     ASSERT(!IsSpecial());
     return DiyFp(Significand(), Exponent());
   }

-  // this->Significand() must not be 0.
+  // The value encode by this Double must be strictly greater than 0.
   DiyFp AsNormalizedDiyFp() const {
+    ASSERT(value() > 0.0);
     uint64_t f = Significand();
     int e = Exponent();

-    ASSERT(f != 0);
-
     // The current double could be a denormal.
     while ((f & kHiddenBit) == 0) {
       f <<= 1;
@@ -144,14 +146,19 @@ class Double {
     return (d64 & kSignMask) == 0? 1: -1;
   }

+ // Precondition: the value encoded by this Double must be greater or equal
+  // than +0.0.
   DiyFp UpperBoundary() const {
+    ASSERT(Sign() > 0);
     return DiyFp(Significand() * 2 + 1, Exponent() - 1);
   }

   // Returns the two boundaries of this.
// The bigger boundary (m_plus) is normalized. The lower boundary has the same
   // exponent as m_plus.
+  // Precondition: the value encoded by this Double must be greater than 0.
   void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const {
+    ASSERT(value() > 0.0);
     DiyFp v = this->AsDiyFp();
     bool significand_is_zero = (v.f() == kHiddenBit);
     DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1));


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

Reply via email to