Skip to content

Commit bcb7530

Browse files
committed
Use wrapping subs instead of saturating subs
1 parent 87ccd40 commit bcb7530

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/uint/boxed/div.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub(crate) fn div_rem_vartime_in_place(x: &mut [Limb], y: &mut [Limb]) {
483483
(x[xi + i + 1 - yc], carry) =
484484
x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry);
485485
}
486-
ct_borrow.select_word(quo, quo.saturating_sub(1))
486+
ct_borrow.select_word(quo, quo.wrapping_sub(1))
487487
};
488488

489489
// Store the quotient within dividend and set x_hi to the current highest word

src/uint/div.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
254254
x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry);
255255
i += 1;
256256
}
257-
ct_borrow.select_word(quo, quo.saturating_sub(1))
257+
ct_borrow.select_word(quo, quo.wrapping_sub(1))
258258
};
259259

260260
// Store the quotient within dividend and set x_hi to the current highest word

src/uint/div_limb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub(crate) const fn div3by2(
178178
// If r < b and q*y[-2] > r*x[-1], then set q = q - 1 and r = r + v1
179179
let done = ConstChoice::from_word_nonzero((rem >> Word::BITS) as Word)
180180
.or(ConstChoice::from_wide_word_le(qy, rx));
181-
quo = done.select_word(quo.saturating_sub(1), quo);
181+
quo = done.select_word(quo.wrapping_sub(1), quo);
182182
rem = done.select_wide_word(rem + (v1_reciprocal.divisor_normalized as WideWord), rem);
183183
i += 1;
184184
}

0 commit comments

Comments
 (0)