Bit Twiddling Hacks
graphics.stanford.edu
graphics.stanford.edu
Mandatory warning: please don't use those unless you really know what you're doing. Most modern CPUs have instructions for computing all of that stuff and the compiler will try to use them. Those clever hacks might actually hurt both readability and performance if they're misused.
Typically on PC architectures (and even on most modern embedded systems) you shouldn't have to use those hacks.
http://www.amazon.com/gp/product/0321842685/ref=s9_simh_gw_p...
http://www.amazon.com/Art-Computer-Programming-Combinatorial...
has a fascinating 200+ page section on Boolean and bitwise tricks and techniques (Knuth: "A trick is a clever idea that can be used once, while a technique is a trick that can be used at least twice.").
But man, if you think you know how to deal with the binary and bitwise operations, please take some time to go through all of the hacks and examine how they work. It's quite possible you learn something new and interesting, which may have surprising applications elsewhere.