Function poplar_util::math::flooring_log2

source ·
pub fn flooring_log2(x: usize) -> usize
Expand description

Fast integer log2 that floors to the lower power-of-2 if x is not a power-of-2. x must not be 0.

§Example

assert_eq!(flooring_log2(1), 0);
assert_eq!(flooring_log2(64), 6);
assert_eq!(flooring_log2(61), 5);
assert_eq!(flooring_log2(4095), 11);