Reputation: 14659
Taking a look at GCC's builtins, I noticed the use of the string pop
in function name (__builtin_popcount
), etc. I've also seen other references to pop in other implementations.
When referring to set bits, why is pop
used, and what does it mean?
Upvotes: 0
Views: 236
Reputation: 24587
It's short for "population" (i.e., the number of bits that are "populated" by being set to 1), and is also known as the Hamming weight.
From Wikipedia:
The Hamming weight of a string is the number of symbols that are different from the zero-symbol of the alphabet used. It is thus equivalent to the Hamming distance from the all-zero string of the same length. For the most typical case, a string of bits, this is the number of 1's in the string. In this binary case, it is also called the population count, popcount or sideways sum. It is the digit sum of the binary representation of a given number and the ℓ₁ norm of a bit vector.
Upvotes: 3