[–] jwilliams 17y ago ↗ The http://graphics.stanford.edu/~seander/bithacks.html#ZeroInWo... hack is reminiscent of the strlen discussion the other day: http://news.ycombinator.com/item?id=510326
[–] nixme 17y 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#CountBit...
[–] henning 17y ago ↗ These are good for showing off to other programmers and ensuring your job security/future contracts at your present place of work. [–] sketerpot 17y ago ↗ Not if you comment properly. Don't worry, these are safe to use!
[–] kqr2 17y ago ↗ Also check out Hacker's Delight :http://www.hackersdelight.org/http://www.amazon.com/Hackers-Delight-Henry-S-Warren/dp/0201...
[–] critic 17y ago ↗ If the number of CPU cores increases significantly, with the individual cores getting much simpler, I wonder if bit twiddling will be back.
6 comments
[ 3.5 ms ] story [ 28.6 ms ] threadMy 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#CountBit...
http://www.hackersdelight.org/
http://www.amazon.com/Hackers-Delight-Henry-S-Warren/dp/0201...