pub trait CeilingModPowerOf2 {
    type Output;

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

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

Required Associated Types§

Required Methods§

source

fn ceiling_mod_power_of_2(self, other: u64) -> Self::Output

Implementations on Foreign Types§

source§

impl CeilingModPowerOf2 for i8

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> i8

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = i8

source§

impl CeilingModPowerOf2 for i16

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> i16

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = i16

source§

impl CeilingModPowerOf2 for i32

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> i32

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = i32

source§

impl CeilingModPowerOf2 for i64

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> i64

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = i64

source§

impl CeilingModPowerOf2 for i128

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> i128

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = i128

source§

impl CeilingModPowerOf2 for isize

source§

fn ceiling_mod_power_of_2(self, pow: u64) -> isize

Divides a number by $2^k$, returning just the remainder. The remainder is non-positive.

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

$$ f(x, y) = x - 2^k\left \lceil \frac{x}{2^k} \right \rceil. $$

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is positive or Self::MIN, and pow is greater than or equal to Self::WIDTH.

§Examples

See here.

§

type Output = isize

Implementors§