| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten); | 87 static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten); |
| 88 | 88 |
| 89 // Maximum number of significant digits in the decimal representation. | 89 // Maximum number of significant digits in the decimal representation. |
| 90 // In fact the value is 772 (see conversions.cc), but to give us some margin | 90 // In fact the value is 772 (see conversions.cc), but to give us some margin |
| 91 // we round up to 780. | 91 // we round up to 780. |
| 92 static const int kMaxSignificantDecimalDigits = 780; | 92 static const int kMaxSignificantDecimalDigits = 780; |
| 93 | 93 |
| 94 static Vector<const char> TrimLeadingZeros(Vector<const char> buffer) { | 94 static Vector<const char> TrimLeadingZeros(Vector<const char> buffer) { |
| 95 for (int i = 0; i < buffer.length(); i++) { | 95 for (int i = 0; i < buffer.length(); i++) { |
| 96 if (buffer[i] != '0') { | 96 if (buffer[i] != '0') { |
| 97 return Vector<const char>(buffer.start() + i, buffer.length() - i); | 97 return buffer.SubVector(i, buffer.length()); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 return Vector<const char>(buffer.start(), 0); | 100 return buffer.SubVector(0, 0); |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 static Vector<const char> TrimTrailingZeros(Vector<const char> buffer) { | 104 static Vector<const char> TrimTrailingZeros(Vector<const char> buffer) { |
| 105 for (int i = buffer.length() - 1; i >= 0; --i) { | 105 for (int i = buffer.length() - 1; i >= 0; --i) { |
| 106 if (buffer[i] != '0') { | 106 if (buffer[i] != '0') { |
| 107 return Vector<const char>(buffer.start(), i + 1); | 107 return buffer.SubVector(0, i + 1); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 return Vector<const char>(buffer.start(), 0); | 110 return buffer.SubVector(0, 0); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 static void TrimToMaxSignificantDigits(Vector<const char> buffer, | 114 static void TrimToMaxSignificantDigits(Vector<const char> buffer, |
| 115 int exponent, | 115 int exponent, |
| 116 char* significant_buffer, | 116 char* significant_buffer, |
| 117 int* significant_exponent) { | 117 int* significant_exponent) { |
| 118 for (int i = 0; i < kMaxSignificantDecimalDigits - 1; ++i) { | 118 for (int i = 0; i < kMaxSignificantDecimalDigits - 1; ++i) { |
| 119 significant_buffer[i] = buffer[i]; | 119 significant_buffer[i] = buffer[i]; |
| 120 } | 120 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 double guess; | 433 double guess; |
| 434 if (DoubleStrtod(trimmed, exponent, &guess) || | 434 if (DoubleStrtod(trimmed, exponent, &guess) || |
| 435 DiyFpStrtod(trimmed, exponent, &guess)) { | 435 DiyFpStrtod(trimmed, exponent, &guess)) { |
| 436 return guess; | 436 return guess; |
| 437 } | 437 } |
| 438 return BignumStrtod(trimmed, exponent, guess); | 438 return BignumStrtod(trimmed, exponent, guess); |
| 439 } | 439 } |
| 440 | 440 |
| 441 } } // namespace v8::internal | 441 } } // namespace v8::internal |
| OLD | NEW |