calculate the exponent, in scientific notation, of the number. this algorithm is not even close to optimized, but it has no practical effect on performance: in order to have a faster algorithm, we'd need to slow down performance for faster algorithms, and this is still fast.
| 2711 | // effect on performance: in order to have a faster algorithm, we'd need |
| 2712 | // to slow down performance for faster algorithms, and this is still fast. |
| 2713 | fastfloat_really_inline FASTFLOAT_CONSTEXPR14 |
| 2714 | int32_t scientific_exponent(parsed_number_string& num) noexcept { |
| 2715 | uint64_t mantissa = num.mantissa; |
| 2716 | int32_t exponent = int32_t(num.exponent); |
| 2717 | while (mantissa >= 10000) { |
| 2718 | mantissa /= 10000; |
| 2719 | exponent += 4; |
| 2720 | } |
| 2721 | while (mantissa >= 100) { |
| 2722 | mantissa /= 100; |
| 2723 | exponent += 2; |
| 2724 | } |
| 2725 | while (mantissa >= 10) { |
| 2726 | mantissa /= 10; |
| 2727 | exponent += 1; |
| 2728 | } |
| 2729 | return exponent; |
| 2730 | } |
| 2731 | |
| 2732 | // this converts a native floating-point number to an extended-precision float. |
| 2733 | template <typename T> |
no outgoing calls
no test coverage detected