Function bitcoin::utils::log2

source ·
pub fn log2(value: u64) -> u32
Expand description

Returns the (ceiled) log base 2 of the value

assert_eq!(bitcoin::utils::log2(4), 2);
assert_eq!(bitcoin::utils::log2(5), 3);
assert_eq!(bitcoin::utils::log2(8), 3);
assert_eq!(bitcoin::utils::log2(256), 8);
assert_eq!(bitcoin::utils::log2(257), 9);
assert_eq!(bitcoin::utils::log2(65536), 16);
assert_eq!(bitcoin::utils::log2(65537), 17);