diff --git a/src/uint/boxed/div.rs b/src/uint/boxed/div.rs index 2957b20b..6663991f 100644 --- a/src/uint/boxed/div.rs +++ b/src/uint/boxed/div.rs @@ -489,7 +489,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 09235390..782c7bc9 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -260,7 +260,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; }