Trait malachite_base::num::arithmetic::traits::CeilingModPowerOf2
source · [−]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
fn ceiling_mod_power_of_2(self, other: u64) -> Self::Output
Implementations on Foreign Types
sourceimpl CeilingModPowerOf2 for i8
impl CeilingModPowerOf2 for i8
sourcefn 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
sourceimpl CeilingModPowerOf2 for i16
impl CeilingModPowerOf2 for i16
sourcefn 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
sourceimpl CeilingModPowerOf2 for i32
impl CeilingModPowerOf2 for i32
sourcefn 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
sourceimpl CeilingModPowerOf2 for i64
impl CeilingModPowerOf2 for i64
sourcefn 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
sourceimpl CeilingModPowerOf2 for i128
impl CeilingModPowerOf2 for i128
sourcefn 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
sourceimpl CeilingModPowerOf2 for isize
impl CeilingModPowerOf2 for isize
sourcefn 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.