Trait malachite_base::num::arithmetic::traits::NextPowerOf2Assign
source · [−]pub trait NextPowerOf2Assign {
fn next_power_of_2_assign(&mut self);
}
Expand description
Replaces a number with the smallest power of 2 greater than or equal it. Assumes the result is representable.
Required Methods
fn next_power_of_2_assign(&mut self)
Implementations on Foreign Types
sourceimpl NextPowerOf2Assign for u8
impl NextPowerOf2Assign for u8
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for u16
impl NextPowerOf2Assign for u16
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for u32
impl NextPowerOf2Assign for u32
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for u64
impl NextPowerOf2Assign for u64
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for u128
impl NextPowerOf2Assign for u128
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for usize
impl NextPowerOf2Assign for usize
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for f32
impl NextPowerOf2Assign for f32
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.
sourceimpl NextPowerOf2Assign for f64
impl NextPowerOf2Assign for f64
sourcefn next_power_of_2_assign(&mut self)
fn next_power_of_2_assign(&mut self)
Replaces a number with the smallest power of 2 greater than or equal to it.
$x \gets 2^{\lceil \log_2 x \rceil}$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if the next power of 2 is greater than the type’s maximum value.
Examples
See here.