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

Divides a number by $2^k$, replacing the number by 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 Methods§

source

fn rem_power_of_2_assign(&mut self, other: u64)

Implementations on Foreign Types§

source§

impl RemPowerOf2Assign for i8

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for i16

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for i32

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for i64

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for i128

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for isize

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

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

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

$$ x \gets 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.

source§

impl RemPowerOf2Assign for u8

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl RemPowerOf2Assign for u16

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl RemPowerOf2Assign for u32

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl RemPowerOf2Assign for u64

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl RemPowerOf2Assign for u128

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

impl RemPowerOf2Assign for usize

source§

fn rem_power_of_2_assign(&mut self, pow: u64)

Divides a number by $2^k$, replacing the first number by the remainder. For unsigned integers, rem_power_of_2_assign is equivalent to mod_power_of_2_assign.

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

$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§