| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // The input buffer has been trimmed. Therefore the last digit must be | 121 // The input buffer has been trimmed. Therefore the last digit must be |
| 122 // different from '0'. | 122 // different from '0'. |
| 123 ASSERT(buffer[buffer.length() - 1] != '0'); | 123 ASSERT(buffer[buffer.length() - 1] != '0'); |
| 124 // Set the last digit to be non-zero. This is sufficient to guarantee | 124 // Set the last digit to be non-zero. This is sufficient to guarantee |
| 125 // correct rounding. | 125 // correct rounding. |
| 126 significant_buffer[kMaxSignificantDecimalDigits - 1] = '1'; | 126 significant_buffer[kMaxSignificantDecimalDigits - 1] = '1'; |
| 127 *significant_exponent = | 127 *significant_exponent = |
| 128 exponent + (buffer.length() - kMaxSignificantDecimalDigits); | 128 exponent + (buffer.length() - kMaxSignificantDecimalDigits); |
| 129 } | 129 } |
| 130 | 130 |
| 131 |
| 131 // Reads digits from the buffer and converts them to a uint64. | 132 // Reads digits from the buffer and converts them to a uint64. |
| 132 // Reads in as many digits as fit into a uint64. | 133 // Reads in as many digits as fit into a uint64. |
| 133 // When the string starts with "1844674407370955161" no further digit is read. | 134 // When the string starts with "1844674407370955161" no further digit is read. |
| 134 // Since 2^64 = 18446744073709551616 it would still be possible read another | 135 // Since 2^64 = 18446744073709551616 it would still be possible read another |
| 135 // digit if it was less or equal than 6, but this would complicate the code. | 136 // digit if it was less or equal than 6, but this would complicate the code. |
| 136 static uint64_t ReadUint64(Vector<const char> buffer, | 137 static uint64_t ReadUint64(Vector<const char> buffer, |
| 137 int* number_of_read_digits) { | 138 int* number_of_read_digits) { |
| 138 uint64_t result = 0; | 139 uint64_t result = 0; |
| 139 int i = 0; | 140 int i = 0; |
| 140 while (i < buffer.length() && result <= (kMaxUint64 / 10 - 1)) { | 141 while (i < buffer.length() && result <= (kMaxUint64 / 10 - 1)) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 434 |
| 434 double guess; | 435 double guess; |
| 435 if (DoubleStrtod(trimmed, exponent, &guess) || | 436 if (DoubleStrtod(trimmed, exponent, &guess) || |
| 436 DiyFpStrtod(trimmed, exponent, &guess)) { | 437 DiyFpStrtod(trimmed, exponent, &guess)) { |
| 437 return guess; | 438 return guess; |
| 438 } | 439 } |
| 439 return BignumStrtod(trimmed, exponent, guess); | 440 return BignumStrtod(trimmed, exponent, guess); |
| 440 } | 441 } |
| 441 | 442 |
| 442 } } // namespace v8::internal | 443 } } // namespace v8::internal |
| OLD | NEW |