The Hamming weight of a word is the number of its nonzero coordinates.
Store the Hamming weight of each possible byte in a 256-entry table. Extract each byte of a word by a logical right shift and a bit mask, then sum its table entries. The byte positions partition the word's bits, proving the formula. A 32-bit word needs four lookups, which can be unrolled. Logical extraction does not depend on the endianness of a stored word. The speed advantage depends on table-access costs as well as instruction counts.

Ancestors (6)

  1. Linear code
  2. Coding theory
  3. Algebra
  4. Area of mathematics
  5. Mathematics
  6. Home

Synonyms (4)

Discussion (0) New discussion

There are no discussions about this article yet.

Articles by others on the same topic (0)

There are currently no matching articles.