Bit Twiddling Hacks
Many public domain algorithms (with C implementations) for low-level messing with bits.
Some examples:
- Compute the minimum or maximum of two integers
- Determining if an integer is a power of 2
- Counting bits set
- Swapping individual bits
- Reversing bit sequences
- Finding integer log base 2 of an integer (aka the position of the highest bit set)
- Counting consecutive trailing zero bits
- Round up to the next highest power of 2
and many more!