Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hamming weight

  • Hamming weight population count (popcount)

The Hamming weight of a string over a finite alphabet is defined as the number of positions in the string whose symbols differ from the zero symbol of the alphabet. In the binary case, which is the most common application, this corresponds to the number of 1s in the binary string. This concept originated in the context of error-detecting and error-correcting codes, where it measures the nonzero components in codewords.

Examples

String (Binary)Hamming WeightExplanation
00000No ’1’s
01012Two ’1’s at positions 1 and 3
11114Four ’1’s
10001013Three ’1’s at positions 0, 4, and 6