Skip to main content
. Author manuscript; available in PMC: 2016 Apr 21.
Published in final edited form as: J Chem Inf Model. 2011 Sep 7;51(9):2345–2351. doi: 10.1021/ci200235e

Figure 1.

Figure 1

Parallel reduction population count of a byte in three stages. We wish to count the number of 1-bits in the byte 11001001 (base-2). In the first reduction stage, pairs of adjacent bits are summed to form counts of the number of bits set in each two-bit chunk. Pairs of 2-bit chunks are then summed into 4-bit chunks, and the 4-bit halves are then summed into the final 8-bit population count 00000100 = 4 bits set (base 10). These sub-byte operations can be implemented in software using shifts, masks, and bytewise addition, as shown in the equations in the right column.