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

Function bitCountF1

libraries/bitHelpers/bitHelpers.cpp:60–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60uint8_t bitCountF1(uint32_t value)
61{
62 // parallel adding in a register SWAG algorithm
63 uint32_t v = value;
64 v = v - ((v >> 1) & 0x55555555);
65 v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
66 v = (v + (v >> 4)) & 0x0F0F0F0F;
67 v = v + (v >> 8);
68 v = v + (v >> 16);
69 return v & 0x0000003F;
70};
71
72
73uint8_t bitCountF2(uint32_t value)

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68