AK: Use correct wide integer type for qhat check in UFixedBigIntDivision

Previously, we were assuming that were always on a 64-bit platform,
which is not 100% correct
This commit is contained in:
Hendiadyoin1 2024-03-17 19:35:28 +01:00 committed by Andrew Kaster
commit 9045840e33
Notes: sideshowbarker 2024-07-17 00:16:31 +09:00

View file

@ -95,7 +95,7 @@ constexpr void div_mod_internal(
qhat = div_mod_words(dividend[i - 1], dividend[i], divisor_approx, rhat);
auto is_qhat_too_large = [&] {
return UFixedBigInt<native_word_size> { qhat }.wide_multiply(divisor[divisor_len - 2]) > u128 { dividend[i - 2], rhat };
return UFixedBigInt<native_word_size> { qhat }.wide_multiply(divisor[divisor_len - 2]) > UFixedBigInt<native_word_size * 2> { dividend[i - 2], rhat };
};
if (is_qhat_too_large()) {
--qhat;