Skip to content

Commit bec0f0c

Browse files
committed
Use wrapping subs instead of saturating subs
1 parent c67d6ac commit bec0f0c

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
@@ -489,7 +489,7 @@ pub(crate) fn div_rem_vartime_in_place(x: &mut [Limb], y: &mut [Limb]) {
489489
(x[xi + i + 1 - yc], carry) =
490490
x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry);
491491
}
492-
ct_borrow.select_word(quo, quo.saturating_sub(1))
492+
ct_borrow.select_word(quo, quo.wrapping_sub(1))
493493
};
494494

495495
// 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
@@ -260,7 +260,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
260260
x[xi + i + 1 - yc].adc(Limb::select(Limb::ZERO, y[i], ct_borrow), carry);
261261
i += 1;
262262
}
263-
ct_borrow.select_word(quo, quo.saturating_sub(1))
263+
ct_borrow.select_word(quo, quo.wrapping_sub(1))
264264
};
265265

266266
// 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)