Index: Source/wtf/dtoa/double.h |
diff --git a/Source/wtf/dtoa/double.h b/Source/wtf/dtoa/double.h |
index 0544fdb5a817fa8216b3e31e65a31912f0787225..d0f449d20f0669586ef7c5ea48918b9223cde83c 100644 |
--- a/Source/wtf/dtoa/double.h |
+++ b/Source/wtf/dtoa/double.h |
@@ -33,11 +33,11 @@ |
namespace WTF { |
namespace double_conversion { |
- |
+ |
// We assume that doubles and uint64_t have the same endianness. |
static uint64_t double_to_uint64(double d) { return BitCast<uint64_t>(d); } |
static double uint64_to_double(uint64_t d64) { return BitCast<double>(d64); } |
- |
+ |
// Helper functions for doubles. |
class Double { |
public: |
@@ -47,13 +47,13 @@ namespace double_conversion { |
static const uint64_t kHiddenBit = UINT64_2PART_C(0x00100000, 00000000); |
static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit. |
static const int kSignificandSize = 53; |
- |
+ |
Double() : d64_(0) {} |
explicit Double(double d) : d64_(double_to_uint64(d)) {} |
explicit Double(uint64_t d64) : d64_(d64) {} |
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 { |
@@ -61,13 +61,13 @@ namespace double_conversion { |
ASSERT(!IsSpecial()); |
return DiyFp(Significand(), Exponent()); |
} |
- |
+ |
// The value encoded by this Double must be strictly greater than 0. |
DiyFp AsNormalizedDiyFp() const { |
ASSERT(value() > 0.0); |
uint64_t f = Significand(); |
int e = Exponent(); |
- |
+ |
// The current double could be a denormal. |
while ((f & kHiddenBit) == 0) { |
f <<= 1; |
@@ -78,12 +78,12 @@ namespace double_conversion { |
e -= DiyFp::kSignificandSize - kSignificandSize; |
return DiyFp(f, e); |
} |
- |
+ |
// Returns the double's bit as uint64. |
uint64_t AsUint64() const { |
return d64_; |
} |
- |
+ |
// Returns the next greater double. Returns +infinity on input +infinity. |
double NextDouble() const { |
if (d64_ == kInfinity) return Double(kInfinity).value(); |
@@ -97,16 +97,16 @@ namespace double_conversion { |
return Double(d64_ + 1).value(); |
} |
} |
- |
+ |
int Exponent() const { |
if (IsDenormal()) return kDenormalExponent; |
- |
+ |
uint64_t d64 = AsUint64(); |
int biased_e = |
static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize); |
return biased_e - kExponentBias; |
} |
- |
+ |
uint64_t Significand() const { |
uint64_t d64 = AsUint64(); |
uint64_t significand = d64 & kSignificandMask; |
@@ -116,44 +116,44 @@ namespace double_conversion { |
return significand; |
} |
} |
- |
+ |
// Returns true if the double is a denormal. |
bool IsDenormal() const { |
uint64_t d64 = AsUint64(); |
return (d64 & kExponentMask) == 0; |
} |
- |
+ |
// We consider denormals not to be special. |
// Hence only Infinity and NaN are special. |
bool IsSpecial() const { |
uint64_t d64 = AsUint64(); |
return (d64 & kExponentMask) == kExponentMask; |
} |
- |
+ |
bool IsNan() const { |
uint64_t d64 = AsUint64(); |
return ((d64 & kExponentMask) == kExponentMask) && |
((d64 & kSignificandMask) != 0); |
} |
- |
+ |
bool IsInfinite() const { |
uint64_t d64 = AsUint64(); |
return ((d64 & kExponentMask) == kExponentMask) && |
((d64 & kSignificandMask) == 0); |
} |
- |
+ |
int Sign() const { |
uint64_t d64 = AsUint64(); |
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); |
} |
- |
+ |
// Computes the two boundaries of this. |
// The bigger boundary (m_plus) is normalized. The lower boundary has the same |
// exponent as m_plus. |
@@ -180,9 +180,9 @@ namespace double_conversion { |
*out_m_plus = m_plus; |
*out_m_minus = m_minus; |
} |
- |
+ |
double value() const { return uint64_to_double(d64_); } |
- |
+ |
// Returns the significand size for a given order of magnitude. |
// If v = f*2^e with 2^p-1 <= f <= 2^p then p+e is v's order of magnitude. |
// This function returns the number of significant binary digits v will have |
@@ -196,24 +196,24 @@ namespace double_conversion { |
if (order <= kDenormalExponent) return 0; |
return order - kDenormalExponent; |
} |
- |
+ |
static double Infinity() { |
return Double(kInfinity).value(); |
} |
- |
+ |
static double NaN() { |
return Double(kNaN).value(); |
} |
- |
+ |
private: |
static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; |
static const int kDenormalExponent = -kExponentBias + 1; |
static const int kMaxExponent = 0x7FF - kExponentBias; |
static const uint64_t kInfinity = UINT64_2PART_C(0x7FF00000, 00000000); |
static const uint64_t kNaN = UINT64_2PART_C(0x7FF80000, 00000000); |
- |
+ |
const uint64_t d64_; |
- |
+ |
static uint64_t DiyFpToUint64(DiyFp diy_fp) { |
uint64_t significand = diy_fp.f(); |
int exponent = diy_fp.e(); |
@@ -241,7 +241,7 @@ namespace double_conversion { |
(biased_exponent << kPhysicalSignificandSize); |
} |
}; |
- |
+ |
} // namespace double_conversion |
} // namespace WTF |