News for hackers. Stuff that matters.
Re:Low Level Bit Hacks You Absolutely Must Know by tptacek on Tuesday June 30, 2009 @04:37PM (#681530)
He didn't even talk about how to do the left-most bit, which is too bad, because getting the left-most bit is more useful than getting the right-most bit.
Re:Low Level Bit Hacks You Absolutely Must Know by pkrumins on Tuesday June 30, 2009 @04:58PM (#681569)
Unfortunately it is not possible to do that efficiently with just a few bit operations because of the following theorem:

Theorem. A function mapping words to words can be implemented with word-parallel add, subtract, and, or, and not instructions if and only if each bit of the result depends only on bits at and to the right of each input operand.

The proof and comments are in the Hacker's Delight book!

That's why it's not in the article.

Re:Low Level Bit Hacks You Absolutely Must Know by tptacek on Tuesday June 30, 2009 @09:17PM (#681927)
I didn't take the article to be "with just a few bit manipulations", but rather "how to start working with bits". But yeah that's a sensible reason not to attempt it.