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

Side by Side Diff: src/strtod.cc

Issue 813813003: Revert of Remove obsolete V8_INFINITY macro. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « src/ppc/lithium-codegen-ppc.cc ('k') | src/types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h>
5 #include <cmath> 6 #include <cmath>
6 #include <cstdarg>
7 #include <limits>
8 7
9 #include "src/v8.h" 8 #include "src/v8.h"
10 9
11 #include "src/bignum.h" 10 #include "src/bignum.h"
12 #include "src/cached-powers.h" 11 #include "src/cached-powers.h"
13 #include "src/double.h" 12 #include "src/double.h"
14 #include "src/globals.h" 13 #include "src/globals.h"
15 #include "src/strtod.h" 14 #include "src/strtod.h"
16 #include "src/utils.h" 15 #include "src/utils.h"
17 16
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Returns the correct double for the buffer*10^exponent. 345 // Returns the correct double for the buffer*10^exponent.
347 // The variable guess should be a close guess that is either the correct double 346 // The variable guess should be a close guess that is either the correct double
348 // or its lower neighbor (the nearest double less than the correct one). 347 // or its lower neighbor (the nearest double less than the correct one).
349 // Preconditions: 348 // Preconditions:
350 // buffer.length() + exponent <= kMaxDecimalPower + 1 349 // buffer.length() + exponent <= kMaxDecimalPower + 1
351 // buffer.length() + exponent > kMinDecimalPower 350 // buffer.length() + exponent > kMinDecimalPower
352 // buffer.length() <= kMaxDecimalSignificantDigits 351 // buffer.length() <= kMaxDecimalSignificantDigits
353 static double BignumStrtod(Vector<const char> buffer, 352 static double BignumStrtod(Vector<const char> buffer,
354 int exponent, 353 int exponent,
355 double guess) { 354 double guess) {
356 if (guess == std::numeric_limits<double>::infinity()) { 355 if (guess == V8_INFINITY) {
357 return guess; 356 return guess;
358 } 357 }
359 358
360 DiyFp upper_boundary = Double(guess).UpperBoundary(); 359 DiyFp upper_boundary = Double(guess).UpperBoundary();
361 360
362 DCHECK(buffer.length() + exponent <= kMaxDecimalPower + 1); 361 DCHECK(buffer.length() + exponent <= kMaxDecimalPower + 1);
363 DCHECK(buffer.length() + exponent > kMinDecimalPower); 362 DCHECK(buffer.length() + exponent > kMinDecimalPower);
364 DCHECK(buffer.length() <= kMaxSignificantDecimalDigits); 363 DCHECK(buffer.length() <= kMaxSignificantDecimalDigits);
365 // Make sure that the Bignum will be able to hold all our numbers. 364 // Make sure that the Bignum will be able to hold all our numbers.
366 // Our Bignum implementation has a separate field for exponents. Shifts will 365 // Our Bignum implementation has a separate field for exponents. Shifts will
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (trimmed.length() == 0) return 0.0; 401 if (trimmed.length() == 0) return 0.0;
403 if (trimmed.length() > kMaxSignificantDecimalDigits) { 402 if (trimmed.length() > kMaxSignificantDecimalDigits) {
404 char significant_buffer[kMaxSignificantDecimalDigits]; 403 char significant_buffer[kMaxSignificantDecimalDigits];
405 int significant_exponent; 404 int significant_exponent;
406 TrimToMaxSignificantDigits(trimmed, exponent, 405 TrimToMaxSignificantDigits(trimmed, exponent,
407 significant_buffer, &significant_exponent); 406 significant_buffer, &significant_exponent);
408 return Strtod(Vector<const char>(significant_buffer, 407 return Strtod(Vector<const char>(significant_buffer,
409 kMaxSignificantDecimalDigits), 408 kMaxSignificantDecimalDigits),
410 significant_exponent); 409 significant_exponent);
411 } 410 }
412 if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) { 411 if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) return V8_INFINITY;
413 return std::numeric_limits<double>::infinity();
414 }
415 if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0; 412 if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0;
416 413
417 double guess; 414 double guess;
418 if (DoubleStrtod(trimmed, exponent, &guess) || 415 if (DoubleStrtod(trimmed, exponent, &guess) ||
419 DiyFpStrtod(trimmed, exponent, &guess)) { 416 DiyFpStrtod(trimmed, exponent, &guess)) {
420 return guess; 417 return guess;
421 } 418 }
422 return BignumStrtod(trimmed, exponent, guess); 419 return BignumStrtod(trimmed, exponent, guess);
423 } 420 }
424 421
425 } } // namespace v8::internal 422 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ppc/lithium-codegen-ppc.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698