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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 707 } |
708 | 708 |
709 | 709 |
710 bool FastDtoa(double v, | 710 bool FastDtoa(double v, |
711 FastDtoaMode mode, | 711 FastDtoaMode mode, |
712 int requested_digits, | 712 int requested_digits, |
713 Vector<char> buffer, | 713 Vector<char> buffer, |
714 int* length, | 714 int* length, |
715 int* decimal_point) { | 715 int* decimal_point) { |
716 ASSERT(v > 0); | 716 ASSERT(v > 0); |
717 ASSERT(!Double(v).IsSpecial()); | 717 DCHECK(!Double(v).IsSpecial()); |
718 | 718 |
719 bool result = false; | 719 bool result = false; |
720 int decimal_exponent = 0; | 720 int decimal_exponent = 0; |
721 switch (mode) { | 721 switch (mode) { |
722 case FAST_DTOA_SHORTEST: | 722 case FAST_DTOA_SHORTEST: |
723 result = Grisu3(v, buffer, length, &decimal_exponent); | 723 result = Grisu3(v, buffer, length, &decimal_exponent); |
724 break; | 724 break; |
725 case FAST_DTOA_PRECISION: | 725 case FAST_DTOA_PRECISION: |
726 result = Grisu3Counted(v, requested_digits, | 726 result = Grisu3Counted(v, requested_digits, |
727 buffer, length, &decimal_exponent); | 727 buffer, length, &decimal_exponent); |
728 break; | 728 break; |
729 default: | 729 default: |
730 UNREACHABLE(); | 730 UNREACHABLE(); |
731 } | 731 } |
732 if (result) { | 732 if (result) { |
733 *decimal_point = *length + decimal_exponent; | 733 *decimal_point = *length + decimal_exponent; |
734 buffer[*length] = '\0'; | 734 buffer[*length] = '\0'; |
735 } | 735 } |
736 return result; | 736 return result; |
737 } | 737 } |
738 | 738 |
739 } // namespace double_conversion | 739 } // namespace double_conversion |
740 | 740 |
741 } // namespace WTF | 741 } // namespace WTF |
OLD | NEW |