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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <limits.h> | 28 #include <limits.h> |
29 #include <math.h> | 29 #include <math.h> |
30 | 30 |
31 #include "double-conversion.h" | 31 #include "double-conversion.h" /* NOLINT */ |
32 | 32 |
33 #include "bignum-dtoa.h" | 33 #include "bignum-dtoa.h" /* NOLINT */ |
34 #include "fast-dtoa.h" | 34 #include "fast-dtoa.h" /* NOLINT */ |
35 #include "fixed-dtoa.h" | 35 #include "fixed-dtoa.h" /* NOLINT */ |
36 #include "ieee.h" | 36 #include "ieee.h" /* NOLINT */ |
37 #include "strtod.h" | 37 #include "strtod.h" /* NOLINT */ |
38 #include "utils.h" | 38 #include "utils.h" /* NOLINT */ |
39 | 39 |
40 namespace double_conversion { | 40 namespace double_conversion { |
41 | 41 |
42 const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { | 42 const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { |
43 int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; | 43 int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN; |
44 static DoubleToStringConverter converter(flags, | 44 static DoubleToStringConverter converter(flags, |
45 "Infinity", | 45 "Infinity", |
46 "NaN", | 46 "NaN", |
47 'e', | 47 'e', |
48 -6, 21, | 48 -6, 21, |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 if ((number & ((int64_t)1 << kSignificandSize)) != 0) { | 570 if ((number & ((int64_t)1 << kSignificandSize)) != 0) { |
571 exponent++; | 571 exponent++; |
572 number >>= 1; | 572 number >>= 1; |
573 } | 573 } |
574 break; | 574 break; |
575 } | 575 } |
576 ++current; | 576 ++current; |
577 } while (current != end); | 577 } while (current != end); |
578 | 578 |
579 ASSERT(number < ((int64_t)1 << kSignificandSize)); | 579 ASSERT(number < ((int64_t)1 << kSignificandSize)); |
580 ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number); | 580 const double double_number = static_cast<double>(number); |
| 581 ASSERT(static_cast<int64_t>(double_number) == number); |
581 | 582 |
582 *trailing_pointer = current; | 583 *trailing_pointer = current; |
583 | 584 |
584 if (exponent == 0) { | 585 if (exponent == 0) { |
585 if (sign) { | 586 if (sign) { |
586 if (number == 0) return -0.0; | 587 if (number == 0) return -0.0; |
587 number = -number; | 588 number = -number; |
588 } | 589 } |
589 return static_cast<double>(number); | 590 return static_cast<double>(number); |
590 } | 591 } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 if (read_as_double) { | 902 if (read_as_double) { |
902 converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 903 converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
903 } else { | 904 } else { |
904 converted = Strtof(Vector<const char>(buffer, buffer_pos), exponent); | 905 converted = Strtof(Vector<const char>(buffer, buffer_pos), exponent); |
905 } | 906 } |
906 *processed_characters_count = static_cast<int>(current - input); | 907 *processed_characters_count = static_cast<int>(current - input); |
907 return sign? -converted: converted; | 908 return sign? -converted: converted; |
908 } | 909 } |
909 | 910 |
910 } // namespace double_conversion | 911 } // namespace double_conversion |
OLD | NEW |