Anyone interested in bit-level tricks like this, should have a copy of Hacker's Delight on their bookshelf.