diff --git a/src/uint/boxed/div.rs b/src/uint/boxed/div.rs index 8a47cf67..3fe257ba 100644 --- a/src/uint/boxed/div.rs +++ b/src/uint/boxed/div.rs @@ -483,7 +483,7 @@ pub(crate) fn div_rem_vartime_in_place(x: &mut [Limb], y: &mut [Limb]) { (x[xi + i + 1 - yc], carry) = x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry); } - ct_borrow.select_word(quo, quo.saturating_sub(1)) + ct_borrow.select_word(quo, quo.wrapping_sub(1)) }; // Store the quotient within dividend and set x_hi to the current highest word diff --git a/src/uint/div.rs b/src/uint/div.rs index 728a5cb7..c434b8b3 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -254,7 +254,7 @@ impl Uint { x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry); i += 1; } - ct_borrow.select_word(quo, quo.saturating_sub(1)) + ct_borrow.select_word(quo, quo.wrapping_sub(1)) }; // Store the quotient within dividend and set x_hi to the current highest word diff --git a/src/uint/div_limb.rs b/src/uint/div_limb.rs index d9142840..775bac64 100644 --- a/src/uint/div_limb.rs +++ b/src/uint/div_limb.rs @@ -178,7 +178,7 @@ pub(crate) const fn div3by2( // If r < b and q*y[-2] > r*x[-1], then set q = q - 1 and r = r + v1 let done = ConstChoice::from_word_nonzero((rem >> Word::BITS) as Word) .or(ConstChoice::from_wide_word_le(qy, rx)); - quo = done.select_word(quo.saturating_sub(1), quo); + quo = done.select_word(quo.wrapping_sub(1), quo); rem = done.select_wide_word(rem + (v1_reciprocal.divisor_normalized as WideWord), rem); i += 1; }