Thursday, February 17, 2011

least significant bt

Obtaining a least signigicant bit of x is very easy: x & (-x). Since x + (-x) = 0 = 2^(word size) the number -x must have the same value of lsb as x. Addition of these two bits yeilds zero and a carry, and this carry is passed all the way to the right leaving zeros in the result. But the latter can only happen if other bits of x and -x are inverse of each other. This completes an explanation

No comments:

Post a Comment