Trait dashu_int::ops::PowerOfTwo
source · pub trait PowerOfTwo {
// Required methods
fn is_power_of_two(&self) -> bool;
fn next_power_of_two(self) -> Self;
}
Expand description
Functions related to the power of two.
Examples
use dashu_base::PowerOfTwo;
let n = 5u32;
assert!(!n.is_power_of_two());
assert_eq!(n.next_power_of_two(), 8);
Required Methods§
sourcefn is_power_of_two(&self) -> bool
fn is_power_of_two(&self) -> bool
Test if self is a power of two (2^k
)
sourcefn next_power_of_two(self) -> Self
fn next_power_of_two(self) -> Self
Get the smallest power of two greater than or equal to self.