uint
uint copied to clipboard
`algorithms/mul`: carry` and `borrow` can probably be merged into a single var.
On 2022-10-24 @recmo wrote in fb3aa20
“Merge pull request #172 from recmo/div2”:
carryand
borrow` can probably be merged into a single var.
/// \begin{aligned}
/// \mathsf{lhs'} &= \mod{\mathsf{lhs} - \mathsf{a} ⋅ \mathsf{b}}_{2^{64⋅N}}
/// \\\\ \mathsf{borrow} &= \floor{\frac{\mathsf{a} ⋅ \mathsf{b} -
/// \mathsf{lhs}}{2^{64⋅N}}} \end{aligned}
/// $$
// OPT: `carry` and `borrow` can probably be merged into a single var.
#[inline(always)]
pub fn submul_nx1(lhs: &mut [u64], a: &[u64], b: u64) -> u64 {
debug_assert_eq!(lhs.len(), a.len());
let mut carry = 0;
let mut borrow = 0;