Hacker News new | past | comments | ask | show | jobs | submit login
Bit Twiddling Hacks (stanford.edu)
49 points by mroman on March 12, 2009 | hide | past | favorite | 6 comments




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...



If the number of CPU cores increases significantly, with the individual cores getting much simpler, I wonder if bit twiddling will be back.


These are good for showing off to other programmers and ensuring your job security/future contracts at your present place of work.


Not if you comment properly. Don't worry, these are safe to use!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: