OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 337 matching lines...) Loading... |
348 } | 348 } |
349 ++current; | 349 ++current; |
350 if (current == end) break; | 350 if (current == end) break; |
351 } | 351 } |
352 | 352 |
353 if (!allow_trailing_junk && | 353 if (!allow_trailing_junk && |
354 AdvanceToNonspace(unicode_cache, ¤t, end)) { | 354 AdvanceToNonspace(unicode_cache, ¤t, end)) { |
355 return JunkStringValue(); | 355 return JunkStringValue(); |
356 } | 356 } |
357 | 357 |
358 ASSERT(buffer_pos < kBufferSize); | 358 SLOW_ASSERT(buffer_pos < kBufferSize); |
359 buffer[buffer_pos] = '\0'; | 359 buffer[buffer_pos] = '\0'; |
360 Vector<const char> buffer_vector(buffer, buffer_pos); | 360 Vector<const char> buffer_vector(buffer, buffer_pos); |
361 return negative ? -Strtod(buffer_vector, 0) : Strtod(buffer_vector, 0); | 361 return negative ? -Strtod(buffer_vector, 0) : Strtod(buffer_vector, 0); |
362 } | 362 } |
363 | 363 |
364 // The following code causes accumulating rounding error for numbers greater | 364 // The following code causes accumulating rounding error for numbers greater |
365 // than ~2^56. It's explicitly allowed in the spec: "if R is not 2, 4, 8, 10, | 365 // than ~2^56. It's explicitly allowed in the spec: "if R is not 2, 4, 8, 10, |
366 // 16, or 32, then mathInt may be an implementation-dependent approximation to | 366 // 16, or 32, then mathInt may be an implementation-dependent approximation to |
367 // the mathematical integer value" (15.1.2.2). | 367 // the mathematical integer value" (15.1.2.2). |
368 | 368 |
(...skipping 316 matching lines...) Loading... |
685 buffer + buffer_pos, | 685 buffer + buffer_pos, |
686 sign == NEGATIVE, | 686 sign == NEGATIVE, |
687 allow_trailing_junk); | 687 allow_trailing_junk); |
688 } | 688 } |
689 | 689 |
690 if (nonzero_digit_dropped) { | 690 if (nonzero_digit_dropped) { |
691 buffer[buffer_pos++] = '1'; | 691 buffer[buffer_pos++] = '1'; |
692 exponent--; | 692 exponent--; |
693 } | 693 } |
694 | 694 |
695 ASSERT(buffer_pos < kBufferSize); | 695 SLOW_ASSERT(buffer_pos < kBufferSize); |
696 buffer[buffer_pos] = '\0'; | 696 buffer[buffer_pos] = '\0'; |
697 | 697 |
698 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 698 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
699 return (sign == NEGATIVE) ? -converted : converted; | 699 return (sign == NEGATIVE) ? -converted : converted; |
700 } | 700 } |
701 | 701 |
702 } } // namespace v8::internal | 702 } } // namespace v8::internal |
703 | 703 |
704 #endif // V8_CONVERSIONS_INL_H_ | 704 #endif // V8_CONVERSIONS_INL_H_ |
OLD | NEW |