3 ms·
Ah... I have some good memories of adapting some of these for microcontrollers while still in school. My favorite is Kernighan's method for counting set bits.
by nixme 18y ago
Ah... I have some good memories of adapting some of these for microcontrollers while still in school.
My favorite is Kernighan's method for counting set bits. It's as short and clean as the naive method and not immediately obvious: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan http://graphics.stanford.edu/~seander/bithacks.html#CountBit...