bitcount
Bitcount, also known as population count or Hamming weight, is the number of 1 bits in the binary representation of an integer. It is a basic bitwise operation used in many algorithms, data structures, and hardware implementations.
A straightforward way to compute bitcount is to repeatedly test the least significant bit and shift the
Faster methods include Kernighan’s algorithm, which iterates only over set bits: while n != 0, n = n
Built-in support is common in programming languages. C/C++ exposes facilities such as __builtin_popcount and __builtin_popcountll; Java
Applications of bitcount include bitboard games and graphics, data compression and cryptography, error detection and correction,