pub fn nearest_power_of_two(n: u64) -> u64Expand description
Nearest power of two to n. Ties round toward even (e.g. 3 -> 4, 5 -> 4).
ยงExamples
use mathverse_core::integer::nearest_power_of_two;
assert_eq!(nearest_power_of_two(1), 1);
assert_eq!(nearest_power_of_two(3), 4);
assert_eq!(nearest_power_of_two(5), 4);
assert_eq!(nearest_power_of_two(6), 8);
assert_eq!(nearest_power_of_two(0), 1);