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

Function bitCountF2

libraries/bitHelpers/bitHelpers.cpp:73–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72
73uint8_t bitCountF2(uint32_t value)
74{
75 // parallel adding in a register SWAG algorithm
76 uint32_t v = value;
77 v = v - ((v >> 1) & 0x55555555);
78 v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
79 v = ((v + (v >> 4)) & 0x0F0F0F0F);
80 return ( v * 0x01010101) >> 24;
81}
82
83
84////////////////////////////////////////////////

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68