| 2806 | |
| 2807 | template <typename callback> |
| 2808 | fastfloat_really_inline FASTFLOAT_CONSTEXPR14 |
| 2809 | void round_nearest_tie_even(adjusted_mantissa& am, int32_t shift, callback cb) noexcept { |
| 2810 | const uint64_t mask |
| 2811 | = (shift == 64) |
| 2812 | ? UINT64_MAX |
| 2813 | : (uint64_t(1) << shift) - 1; |
| 2814 | const uint64_t halfway |
| 2815 | = (shift == 0) |
| 2816 | ? 0 |
| 2817 | : uint64_t(1) << (shift - 1); |
| 2818 | uint64_t truncated_bits = am.mantissa & mask; |
| 2819 | bool is_above = truncated_bits > halfway; |
| 2820 | bool is_halfway = truncated_bits == halfway; |
| 2821 | |
| 2822 | // shift digits into position |
| 2823 | if (shift == 64) { |
| 2824 | am.mantissa = 0; |
| 2825 | } else { |
| 2826 | am.mantissa >>= shift; |
| 2827 | } |
| 2828 | am.power2 += shift; |
| 2829 | |
| 2830 | bool is_odd = (am.mantissa & 1) == 1; |
| 2831 | am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above)); |
| 2832 | } |
| 2833 | |
| 2834 | fastfloat_really_inline FASTFLOAT_CONSTEXPR14 |
| 2835 | void round_down(adjusted_mantissa& am, int32_t shift) noexcept { |
no outgoing calls
no test coverage detected