| 2732 | // this converts a native floating-point number to an extended-precision float. |
| 2733 | template <typename T> |
| 2734 | fastfloat_really_inline FASTFLOAT_CONSTEXPR20 |
| 2735 | adjusted_mantissa to_extended(T value) noexcept { |
| 2736 | using equiv_uint = typename binary_format<T>::equiv_uint; |
| 2737 | constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask(); |
| 2738 | constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask(); |
| 2739 | constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask(); |
| 2740 | |
| 2741 | adjusted_mantissa am; |
| 2742 | int32_t bias = binary_format<T>::mantissa_explicit_bits() - binary_format<T>::minimum_exponent(); |
| 2743 | equiv_uint bits; |
| 2744 | #if FASTFLOAT_HAS_BIT_CAST |
| 2745 | bits = std::bit_cast<equiv_uint>(value); |
| 2746 | #else |
| 2747 | ::memcpy(&bits, &value, sizeof(T)); |
| 2748 | #endif |
| 2749 | if ((bits & exponent_mask) == 0) { |
| 2750 | // denormal |
| 2751 | am.power2 = 1 - bias; |
| 2752 | am.mantissa = bits & mantissa_mask; |
| 2753 | } else { |
| 2754 | // normal |
| 2755 | am.power2 = int32_t((bits & exponent_mask) >> binary_format<T>::mantissa_explicit_bits()); |
| 2756 | am.power2 -= bias; |
| 2757 | am.mantissa = (bits & mantissa_mask) | hidden_bit_mask; |
| 2758 | } |
| 2759 | |
| 2760 | return am; |
| 2761 | } |
| 2762 | |
| 2763 | // get the extended precision value of the halfway point between b and b+u. |
| 2764 | // we are given a native float that represents b, so we need to adjust it |
no outgoing calls
no test coverage detected