MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / bitCountKR

Function bitCountKR

libraries/bitHelpers/bitHelpers.cpp:32–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32uint8_t bitCountKR(uint32_t value)
33{
34 // Kerningham & Ritchie
35 uint32_t v = value;
36 uint8_t count = 0;
37 while (v)
38 {
39 count++;
40 v &= (v - 1);
41 }
42 return count;
43}
44
45
46uint8_t bitCountArray(uint32_t value)

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68