pub trait NegModPowerOf2Assign {
    // Required method
    fn neg_mod_power_of_2_assign(&mut self, other: u64);
}
Expand description

Divides the negative of a number by $2^k$, replacing the number by the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

Required Methods§

source

fn neg_mod_power_of_2_assign(&mut self, other: u64)

Implementations on Foreign Types§

source§

impl NegModPowerOf2Assign for u8

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

source§

impl NegModPowerOf2Assign for u16

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

source§

impl NegModPowerOf2Assign for u32

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

source§

impl NegModPowerOf2Assign for u64

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

source§

impl NegModPowerOf2Assign for u128

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

source§

impl NegModPowerOf2Assign for usize

source§

fn neg_mod_power_of_2_assign(&mut self, pow: u64)

Divides the negative of a number by $2^k$, returning just the remainder.

If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.

$$ x \gets 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is nonzero and pow is greater than Self::WIDTH.

§Examples

See here.

Implementors§