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§
fn ceiling_mod_power_of_2(self, other: u64) -> Self::Output
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl CeilingModPowerOf2 for i8
impl CeilingModPowerOf2 for i8
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> i8
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
impl CeilingModPowerOf2 for i16
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> i16
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
impl CeilingModPowerOf2 for i32
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> i32
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
impl CeilingModPowerOf2 for i64
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> i64
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
impl CeilingModPowerOf2 for i128
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> i128
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
impl CeilingModPowerOf2 for isize
Source§fn ceiling_mod_power_of_2(self, pow: u64) -> isize
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.