pub trait CarryingMul: Sized {
type Output;
// Required methods
fn carrying_mul(
self,
rhs: Self,
carry: Self,
) -> (Self::Output, Self::Output);
fn carrying_mul_add(
self,
rhs: Self,
addend: Self,
carry: Self,
) -> (Self::Output, Self::Output);
}Expand description
Carrying multiplication for extended precision arithmetic.
Provides multiply-accumulate operations returning double-width results.
This is the non-const version that delegates to ConstCarryingMul implementations.
Required Associated Types§
Required Methods§
Sourcefn carrying_mul(self, rhs: Self, carry: Self) -> (Self::Output, Self::Output)
fn carrying_mul(self, rhs: Self, carry: Self) -> (Self::Output, Self::Output)
Calculates self * rhs + carry, returning (low, high).
The result fits in double-width (2 * BITS) since
MAX * MAX + MAX < (MAX+1)^2 = 2^(2*BITS).
Sourcefn carrying_mul_add(
self,
rhs: Self,
addend: Self,
carry: Self,
) -> (Self::Output, Self::Output)
fn carrying_mul_add( self, rhs: Self, addend: Self, carry: Self, ) -> (Self::Output, Self::Output)
Calculates self * rhs + addend + carry, returning (low, high).
The result fits in double-width (2 * BITS) since
MAX * MAX + MAX + MAX < (MAX+1)^2 = 2^(2*BITS).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl CarryingMul for &u8
impl CarryingMul for &u8
Source§impl CarryingMul for &u16
impl CarryingMul for &u16
Source§impl CarryingMul for &u32
impl CarryingMul for &u32
Source§impl CarryingMul for &u64
impl CarryingMul for &u64
Source§impl CarryingMul for u8
impl CarryingMul for u8
type Output = u8
fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)
fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)
Source§impl CarryingMul for u16
impl CarryingMul for u16
type Output = u16
fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)
fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)
Source§impl CarryingMul for u32
impl CarryingMul for u32
type Output = u32
fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)
fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)
Source§impl CarryingMul for u64
impl CarryingMul for u64
type Output = u64
fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)
fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)
Implementors§
Source§impl<T: ConstMachineWord + ConstCarryingAdd + ConstBorrowingSub + MachineWord, const N: usize, P: Personality> CarryingMul for &FixedUInt<T, N, P>
Ref-based carrying multiplication — allows calling with references.
impl<T: ConstMachineWord + ConstCarryingAdd + ConstBorrowingSub + MachineWord, const N: usize, P: Personality> CarryingMul for &FixedUInt<T, N, P>
Ref-based carrying multiplication — allows calling with references.
Source§impl<T: ConstMachineWord + ConstCarryingAdd + ConstBorrowingSub + MachineWord, const N: usize, P: Personality> CarryingMul for FixedUInt<T, N, P>
Non-const carrying multiplication that delegates to ConstCarryingMul.
impl<T: ConstMachineWord + ConstCarryingAdd + ConstBorrowingSub + MachineWord, const N: usize, P: Personality> CarryingMul for FixedUInt<T, N, P>
Non-const carrying multiplication that delegates to ConstCarryingMul.