diff --git a/include/fast_float/digit_comparison.h b/include/fast_float/digit_comparison.h index 3041fe7..ca5f103 100644 --- a/include/fast_float/digit_comparison.h +++ b/include/fast_float/digit_comparison.h @@ -346,16 +346,17 @@ parse_mantissa(bigint &result, const parsed_number_string_t &num) noexcept { template inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa positive_digit_comp( - bigint &bigmant, adjusted_mantissa am, am_pow_t const exponent) noexcept { + bigint &bigmant, am_pow_t const exponent) noexcept { FASTFLOAT_ASSERT(bigmant.pow10(exponent)); + adjusted_mantissa answer; bool truncated; - am.mantissa = bigmant.hi64(truncated); + answer.mantissa = bigmant.hi64(truncated); constexpr am_pow_t bias = binary_format::mantissa_explicit_bits() - binary_format::minimum_exponent(); - am.power2 = + answer.power2 = static_cast(bigmant.bit_length() - 64 + bias); - round(am, [truncated](adjusted_mantissa &a, am_pow_t shift) { + round(answer, [truncated](adjusted_mantissa &a, am_pow_t shift) { round_nearest_tie_even( a, shift, [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool { @@ -364,7 +365,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa positive_digit_comp( }); }); - return am; + return answer; } // the scaling here is quite simple: we have, for the real digits `m * 10^e`, @@ -410,6 +411,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp( // compare digits, and use it to direct rounding int ord = real_digits.compare(theor_digits); + adjusted_mantissa answer = am; round(am, [ord](adjusted_mantissa &a, am_pow_t shift) { round_nearest_tie_even( a, shift, [ord](bool is_odd, bool _, bool __) -> bool { @@ -425,7 +427,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp( }); }); - return am; + return answer; } // parse the significant digits as a big integer to unambiguously round @@ -454,7 +456,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa digit_comp( am_pow_t const exponent = static_cast(sci_exp + 1 - static_cast(digits)); if (exponent >= 0) { - return positive_digit_comp(bigmant, am, exponent); + return positive_digit_comp(bigmant, exponent); } else { return negative_digit_comp(bigmant, am, exponent); }