forge::revm::interpreter::primitives::alloy_primitives::ruint::algorithms

Function submul_nx1

pub fn submul_nx1(lhs: &mut [u64], a: &[u64], b: u64) -> u64
Expand description

Computes lhs -= a * b and returns the borrow.

Requires lhs.len() == a.len().

$$ \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} $$