| 3023 | // are of the same magnitude. |
| 3024 | template <typename T> |
| 3025 | inline FASTFLOAT_CONSTEXPR20 |
| 3026 | adjusted_mantissa negative_digit_comp(bigint& bigmant, adjusted_mantissa am, int32_t exponent) noexcept { |
| 3027 | bigint& real_digits = bigmant; |
| 3028 | int32_t real_exp = exponent; |
| 3029 | |
| 3030 | // get the value of `b`, rounded down, and get a bigint representation of b+h |
| 3031 | adjusted_mantissa am_b = am; |
| 3032 | // gcc7 buf: use a lambda to remove the noexcept qualifier bug with -Wnoexcept-type. |
| 3033 | round<T>(am_b, [](adjusted_mantissa&a, int32_t shift) { round_down(a, shift); }); |
| 3034 | T b; |
| 3035 | to_float(false, am_b, b); |
| 3036 | adjusted_mantissa theor = to_extended_halfway(b); |
| 3037 | bigint theor_digits(theor.mantissa); |
| 3038 | int32_t theor_exp = theor.power2; |
| 3039 | |
| 3040 | // scale real digits and theor digits to be same power. |
| 3041 | int32_t pow2_exp = theor_exp - real_exp; |
| 3042 | uint32_t pow5_exp = uint32_t(-real_exp); |
| 3043 | if (pow5_exp != 0) { |
| 3044 | FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp)); |
| 3045 | } |
| 3046 | if (pow2_exp > 0) { |
| 3047 | FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp))); |
| 3048 | } else if (pow2_exp < 0) { |
| 3049 | FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp))); |
| 3050 | } |
| 3051 | |
| 3052 | // compare digits, and use it to director rounding |
| 3053 | int ord = real_digits.compare(theor_digits); |
| 3054 | adjusted_mantissa answer = am; |
| 3055 | round<T>(answer, [ord](adjusted_mantissa& a, int32_t shift) { |
| 3056 | round_nearest_tie_even(a, shift, [ord](bool is_odd, bool _, bool __) -> bool { |
| 3057 | (void)_; // not needed, since we've done our comparison |
| 3058 | (void)__; // not needed, since we've done our comparison |
| 3059 | if (ord > 0) { |
| 3060 | return true; |
| 3061 | } else if (ord < 0) { |
| 3062 | return false; |
| 3063 | } else { |
| 3064 | return is_odd; |
| 3065 | } |
| 3066 | }); |
| 3067 | }); |
| 3068 | |
| 3069 | return answer; |
| 3070 | } |
| 3071 | |
| 3072 | // parse the significant digits as a big integer to unambiguously round the |
| 3073 | // the significant digits. here, we are trying to determine how to round |
nothing calls this directly
no test coverage detected