pub trait ModPowerOf2Assign {
// Required method
fn mod_power_of_2_assign(&mut self, other: u64);
}Expand description
Divides a number by $2^k$, replacing the number by the remainder. The remainder is non-negative.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k + r$ and $0 \leq r < 2^k$.
Required Methods§
fn mod_power_of_2_assign(&mut self, other: u64)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ModPowerOf2Assign for i8
impl ModPowerOf2Assign for i8
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for i16
impl ModPowerOf2Assign for i16
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for i32
impl ModPowerOf2Assign for i32
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for i64
impl ModPowerOf2Assign for i64
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for i128
impl ModPowerOf2Assign for i128
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for isize
impl ModPowerOf2Assign for isize
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first number by the remainder. The remainder is non-negative.
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\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self is negative and pow is greater than or equal to Self::WIDTH.
§Examples
See here.
Source§impl ModPowerOf2Assign for u8
impl ModPowerOf2Assign for u8
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ 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 ModPowerOf2Assign for u16
impl ModPowerOf2Assign for u16
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ 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 ModPowerOf2Assign for u32
impl ModPowerOf2Assign for u32
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ 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 ModPowerOf2Assign for u64
impl ModPowerOf2Assign for u64
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ 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 ModPowerOf2Assign for u128
impl ModPowerOf2Assign for u128
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ 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 ModPowerOf2Assign for usize
impl ModPowerOf2Assign for usize
Source§fn mod_power_of_2_assign(&mut self, pow: u64)
fn mod_power_of_2_assign(&mut self, pow: u64)
Divides a number by $2^k$, replacing the first 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$.
$$ x \gets x - 2^k\left \lfloor \frac{x}{2^k} \right \rfloor. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.