Skip to main content

CarryingMul

Trait CarryingMul 

Source
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§

Source

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).

Source

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

Source§

type Output = u8

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (u8, u8)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (u8, u8)

Source§

impl CarryingMul for &u16

Source§

type Output = u16

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (u16, u16)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (u16, u16)

Source§

impl CarryingMul for &u32

Source§

type Output = u32

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (u32, u32)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (u32, u32)

Source§

impl CarryingMul for &u64

Source§

type Output = u64

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (u64, u64)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (u64, u64)

Source§

impl CarryingMul for u8

Source§

type Output = u8

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)

Source§

impl CarryingMul for u16

Source§

type Output = u16

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)

Source§

impl CarryingMul for u32

Source§

type Output = u32

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)

Source§

fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self)

Source§

impl CarryingMul for u64

Source§

type Output = u64

Source§

fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self)

Source§

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.

Source§

type Output = FixedUInt<T, N, P>

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.

Source§

type Output = FixedUInt<T, N, P>