Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1590)

Unified Diff: Source/wtf/dtoa/strtod.cc

Issue 20652002: Fix trailing whitespace in scripts and misc. files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't change literal diff. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/dtoa/fixed-dtoa.cc ('k') | Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/dtoa/strtod.cc
diff --git a/Source/wtf/dtoa/strtod.cc b/Source/wtf/dtoa/strtod.cc
index 477e7158c373751da67623b2ae96b521f83d993e..06f28cd9e6c69e6d50becfc795d6f5643dba3f1d 100644
--- a/Source/wtf/dtoa/strtod.cc
+++ b/Source/wtf/dtoa/strtod.cc
@@ -38,14 +38,14 @@
namespace WTF {
namespace double_conversion {
-
+
// 2^53 = 9007199254740992.
// Any integer with at most 15 decimal digits will hence fit into a double
// (which has a 53bit significand) without loss of precision.
static const int kMaxExactDoubleIntegerDecimalDigits = 15;
// 2^64 = 18446744073709551616 > 10^19
static const int kMaxUint64DecimalDigits = 19;
-
+
// Max double: 1.7976931348623157 x 10^308
// Min non-zero double: 4.9406564584124654 x 10^-324
// Any x >= 10^309 is interpreted as +infinity.
@@ -54,11 +54,11 @@ namespace double_conversion {
// as non-zero (equal to the min non-zero double).
static const int kMaxDecimalPower = 309;
static const int kMinDecimalPower = -324;
-
+
// 2^64 = 18446744073709551616
static const uint64_t kMaxUint64 = UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF);
-
-
+
+
static const double exact_powers_of_ten[] = {
1.0, // 10^0
10.0,
@@ -86,12 +86,12 @@ namespace double_conversion {
10000000000000000000000.0
};
static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten);
-
+
// Maximum number of significant digits in the decimal representation.
// In fact the value is 772 (see conversions.cc), but to give us some margin
// we round up to 780.
static const int kMaxSignificantDecimalDigits = 780;
-
+
static Vector<const char> TrimLeadingZeros(Vector<const char> buffer) {
for (int i = 0; i < buffer.length(); i++) {
if (buffer[i] != '0') {
@@ -100,8 +100,8 @@ namespace double_conversion {
}
return Vector<const char>(buffer.start(), 0);
}
-
-
+
+
static Vector<const char> TrimTrailingZeros(Vector<const char> buffer) {
for (int i = buffer.length() - 1; i >= 0; --i) {
if (buffer[i] != '0') {
@@ -110,8 +110,8 @@ namespace double_conversion {
}
return Vector<const char>(buffer.start(), 0);
}
-
-
+
+
static void TrimToMaxSignificantDigits(Vector<const char> buffer,
int exponent,
char* significant_buffer,
@@ -128,7 +128,7 @@ namespace double_conversion {
*significant_exponent =
exponent + (buffer.length() - kMaxSignificantDecimalDigits);
}
-
+
// Reads digits from the buffer and converts them to a uint64.
// Reads in as many digits as fit into a uint64.
// When the string starts with "1844674407370955161" no further digit is read.
@@ -146,8 +146,8 @@ namespace double_conversion {
*number_of_read_digits = i;
return result;
}
-
-
+
+
// Reads a DiyFp from the buffer.
// The returned DiyFp is not necessarily normalized.
// If remaining_decimals is zero then the returned DiyFp is accurate.
@@ -171,8 +171,8 @@ namespace double_conversion {
*remaining_decimals = buffer.length() - read_digits;
}
}
-
-
+
+
static bool DoubleStrtod(Vector<const char> trimmed,
int exponent,
double* result) {
@@ -223,8 +223,8 @@ namespace double_conversion {
}
return false;
}
-
-
+
+
// Returns 10^exponent as an exact DiyFp.
// The given exponent must be in the range [1; kDecimalExponentDistance[.
static DiyFp AdjustmentPowerOfTen(int exponent) {
@@ -246,8 +246,8 @@ namespace double_conversion {
return DiyFp(0, 0);
}
}
-
-
+
+
// If the function returns true then the result is the correct double.
// Otherwise it is either the correct double or the double that is just below
// the correct double.
@@ -267,11 +267,11 @@ namespace double_conversion {
// Move the remaining decimals into the exponent.
exponent += remaining_decimals;
int error = (remaining_decimals == 0 ? 0 : kDenominator / 2);
-
+
int old_e = input.e();
input.Normalize();
error <<= old_e - input.e();
-
+
ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent);
if (exponent < PowersOfTenCache::kMinDecimalExponent) {
*result = 0.0;
@@ -282,7 +282,7 @@ namespace double_conversion {
PowersOfTenCache::GetCachedPowerForDecimalExponent(exponent,
&cached_power,
&cached_decimal_exponent);
-
+
if (cached_decimal_exponent != exponent) {
int adjustment_exponent = exponent - cached_decimal_exponent;
DiyFp adjustment_power = AdjustmentPowerOfTen(adjustment_exponent);
@@ -296,7 +296,7 @@ namespace double_conversion {
error += kDenominator / 2;
}
}
-
+
input.Multiply(cached_power);
// The error introduced by a multiplication of a*b equals
// error_a + error_b + error_a*error_b/2^64 + 0.5
@@ -307,11 +307,11 @@ namespace double_conversion {
int error_ab = (error == 0 ? 0 : 1); // We round up to 1.
int fixed_error = kDenominator / 2;
error += error_b + error_ab + fixed_error;
-
+
old_e = input.e();
input.Normalize();
error <<= old_e - input.e();
-
+
// See if the double's significand changes if we add/subtract the error.
int order_of_magnitude = DiyFp::kSignificandSize + input.e();
int effective_significand_size =
@@ -348,7 +348,7 @@ namespace double_conversion {
// If the last_bits are too close to the half-way case than we are too
// inaccurate and round down. In this case we return false so that we can
// fall back to a more precise algorithm.
-
+
*result = Double(rounded_input).value();
if (half_way - error < precision_bits && precision_bits < half_way + error) {
// Too imprecise. The caller will have to fall back to a slower version.
@@ -359,8 +359,8 @@ namespace double_conversion {
return true;
}
}
-
-
+
+
// Returns the correct double for the buffer*10^exponent.
// The variable guess should be a close guess that is either the correct double
// or its lower neighbor (the nearest double less than the correct one).
@@ -374,9 +374,9 @@ namespace double_conversion {
if (guess == Double::Infinity()) {
return guess;
}
-
+
DiyFp upper_boundary = Double(guess).UpperBoundary();
-
+
ASSERT(buffer.length() + exponent <= kMaxDecimalPower + 1);
ASSERT(buffer.length() + exponent > kMinDecimalPower);
ASSERT(buffer.length() <= kMaxSignificantDecimalDigits);
@@ -411,8 +411,8 @@ namespace double_conversion {
return Double(guess).NextDouble();
}
}
-
-
+
+
double Strtod(Vector<const char> buffer, int exponent) {
Vector<const char> left_trimmed = TrimLeadingZeros(buffer);
Vector<const char> trimmed = TrimTrailingZeros(left_trimmed);
@@ -433,7 +433,7 @@ namespace double_conversion {
if (exponent + trimmed.length() <= kMinDecimalPower) {
return 0.0;
}
-
+
double guess;
if (DoubleStrtod(trimmed, exponent, &guess) ||
DiyFpStrtod(trimmed, exponent, &guess)) {
@@ -441,7 +441,7 @@ namespace double_conversion {
}
return BignumStrtod(trimmed, exponent, guess);
}
-
+
} // namespace double_conversion
} // namespace WTF
« no previous file with comments | « Source/wtf/dtoa/fixed-dtoa.cc ('k') | Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698