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

Function bitCount

libraries/bitHelpers/bitHelpers.cpp:88–96  ·  view source on GitHub ↗

/////////////////////////////////////////// BIT COUNT

Source from the content-addressed store, hash-verified

86// BIT COUNT
87//
88uint8_t bitCount(uint8_t value)
89{
90 // parallel adding in a register SWAG algorithm
91 uint8_t v = value;
92 v = v - ((v >> 1) & 0x55);
93 v = (v & 0x33) + ((v >> 2) & 0x33);
94 v = (v + (v >> 4)) & 0x0F;
95 return v;
96}
97
98
99uint8_t bitCount(uint16_t value)

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68