Skip to main content

popcount

Function popcount 

Source
pub const fn popcount(n: u64) -> u32
Expand description

Population count: number of set bits (1-bits) in n.

ยงExamples

use mathverse_core::integer::popcount;

assert_eq!(popcount(0), 0);
assert_eq!(popcount(7), 3);
assert_eq!(popcount(u64::MAX), 64);