pub trait RemPowerOf2 {
    type Output;

    fn rem_power_of_2(self, other: u64) -> Self::Output;
}
Expand description

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the number.

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. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. For unsigned integers, rem_power_of_2 is equivalent to mod_power_of_2.

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

$$ f(x, k) = x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Divides a number by $2^k$, returning just the remainder. The remainder has the same sign as the first number.

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

$$ f(x, k) = x - 2^k\operatorname{sgn}(x)\left \lfloor \frac{|x|}{2^k} \right \rfloor. $$

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors