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.
[ Parent
| on HN ]
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.