For those who just want quick and efficient solutions to lots of bit-hacking problems (rather than try to become a bit-guru yourself): <a href="http://graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html</a>