Skip to main content

ModPowerOf2Sub

Trait ModPowerOf2Sub 

Source
pub trait ModPowerOf2Sub<RHS = Self> {
    type Output;

    // Required method
    fn mod_power_of_2_sub(self, other: RHS, pow: u64) -> Self::Output;
}
Expand description

Subtracts two numbers modulo $2^k$. The inputs must be already reduced modulo $2^k$.

Required Associated Types§

Required Methods§

Source

fn mod_power_of_2_sub(self, other: RHS, pow: u64) -> Self::Output

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ModPowerOf2Sub for u8

Source§

fn mod_power_of_2_sub(self, other: u8, pow: u64) -> u8

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u8

Source§

impl ModPowerOf2Sub for u16

Source§

fn mod_power_of_2_sub(self, other: u16, pow: u64) -> u16

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u16

Source§

impl ModPowerOf2Sub for u32

Source§

fn mod_power_of_2_sub(self, other: u32, pow: u64) -> u32

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u32

Source§

impl ModPowerOf2Sub for u64

Source§

fn mod_power_of_2_sub(self, other: u64, pow: u64) -> u64

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u64

Source§

impl ModPowerOf2Sub for u128

Source§

fn mod_power_of_2_sub(self, other: u128, pow: u64) -> u128

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u128

Source§

impl ModPowerOf2Sub for usize

Source§

fn mod_power_of_2_sub(self, other: usize, pow: u64) -> usize

Subtracts two numbers modulo a third number $2^k$. The inputs must be already reduced modulo $2^k$.

$f(x, y, k) = z$, where $x, y, z < 2^k$ and $x - y \equiv z \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self or other are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = usize

Implementors§