Trait malachite_base::num::arithmetic::traits::NegModPowerOf2
source · pub trait NegModPowerOf2 {
type Output;
// Required method
fn neg_mod_power_of_2(self, other: u64) -> Self::Output;
}
Expand description
Divides the negative of a number by $2^k$, returning the remainder.
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 neg_mod_power_of_2(self, other: u64) -> Self::Output
Implementations on Foreign Types§
source§impl NegModPowerOf2 for u8
impl NegModPowerOf2 for u8
source§fn neg_mod_power_of_2(self, pow: u64) -> u8
fn neg_mod_power_of_2(self, pow: u64) -> u8
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.
type Output = u8
source§impl NegModPowerOf2 for u16
impl NegModPowerOf2 for u16
source§fn neg_mod_power_of_2(self, pow: u64) -> u16
fn neg_mod_power_of_2(self, pow: u64) -> u16
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.
type Output = u16
source§impl NegModPowerOf2 for u32
impl NegModPowerOf2 for u32
source§fn neg_mod_power_of_2(self, pow: u64) -> u32
fn neg_mod_power_of_2(self, pow: u64) -> u32
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.
type Output = u32
source§impl NegModPowerOf2 for u64
impl NegModPowerOf2 for u64
source§fn neg_mod_power_of_2(self, pow: u64) -> u64
fn neg_mod_power_of_2(self, pow: u64) -> u64
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.
type Output = u64
source§impl NegModPowerOf2 for u128
impl NegModPowerOf2 for u128
source§fn neg_mod_power_of_2(self, pow: u64) -> u128
fn neg_mod_power_of_2(self, pow: u64) -> u128
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.
type Output = u128
source§impl NegModPowerOf2 for usize
impl NegModPowerOf2 for usize
source§fn neg_mod_power_of_2(self, pow: u64) -> usize
fn neg_mod_power_of_2(self, pow: u64) -> usize
Divides the negative of a number by a $2^k$, returning just the remainder.
If the quotient were computed, the quotient and remainder would satisfy $x = q2^k - r$ and $0 \leq r < 2^k$.
$$ f(x, k) = 2^k\left \lceil \frac{x}{2^k} \right \rceil - x. $$
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if self
is nonzero and pow
is greater than Self::WIDTH
.
§Examples
See here.