MCPcopy
hub / github.com/jwasham/practice-python / pop_count

Function pop_count

bit_manipulation/bits.py:24–27  ·  view source on GitHub ↗
(i)

Source from the content-addressed store, hash-verified

22
23
24def pop_count(i):
25 i -= ((i >> 1) & 0x55555555)
26 i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
27 return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
28
29
30def is_bit_set(x, pos):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected