pub const fn log2(x: usize) -> u32
Expand description
Returns the ceiling of the base-2 logarithm of x
.
use ark_std::log2;
assert_eq!(log2(16), 4);
assert_eq!(log2(17), 5);
assert_eq!(log2(1), 0);
assert_eq!(log2(0), 0);
assert_eq!(log2(usize::MAX), (core::mem::size_of::<usize>() * 8) as u32);
assert_eq!(log2(1 << 15), 15);
assert_eq!(log2(2usize.pow(18)), 18);