| 825 | } |
| 826 | |
| 827 | static sonic_force_inline char* FormatExponent(F64Decimal v, char* out, |
| 828 | unsigned cnt) { |
| 829 | char* p = out + 1; |
| 830 | char* end = FormatSignificand(v.sig, p, cnt); |
| 831 | while (*(end - 1) == '0') end--; |
| 832 | |
| 833 | /* print decimal point if needed */ |
| 834 | *out = *p; |
| 835 | if (end - p > 1) { |
| 836 | *p = '.'; |
| 837 | } else { |
| 838 | end--; |
| 839 | } |
| 840 | |
| 841 | /* print the exponent */ |
| 842 | *end++ = 'e'; |
| 843 | int32_t exp = v.exp + (int32_t)cnt - 1; |
| 844 | if (exp < 0) { |
| 845 | *end++ = '-'; |
| 846 | exp = -exp; |
| 847 | } else { |
| 848 | *end++ = '+'; |
| 849 | } |
| 850 | |
| 851 | if (exp >= 100) { |
| 852 | int32_t c = exp % 10; |
| 853 | Copy2Digs(end, kDigits + 2 * (exp / 10)); |
| 854 | end[2] = (char)('0' + c); |
| 855 | end += 3; |
| 856 | } else if (exp >= 10) { |
| 857 | Copy2Digs(end, kDigits + 2 * exp); |
| 858 | end += 2; |
| 859 | } else { |
| 860 | *end++ = (char)('0' + exp); |
| 861 | } |
| 862 | return end; |
| 863 | } |
| 864 | |
| 865 | static sonic_force_inline char* FormatDecimal(F64Decimal v, char* out, |
| 866 | unsigned cnt) { |
no test coverage detected