pub trait CeilingModPowerOf2 {
    type Output;

    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

Implementations on Foreign Types

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.

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.

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.

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.

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.

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.

Implementors