VIII.1 – BIT PICKING

Publisher Summary This chapter discusses different aspects of bit picking. Some computer architectures, such as the Motorola 68020, include an instruction for finding the highest 1-bit set in a word, presumably to assist in software normalization of floating-point operation results. This high 1 finding can be quite handy for other bit vector operations as well. Finding the lowest 1-bit set in a word is a different matter. However, using the properties of 2's-complement arithmetic, it can be done easily. It is suggested to simply take the bit-wise and of the word and its negative; the result will be a word containing just the lowest 1-bit. It is found that if n is exactly a power of 2, then n = (n and −n) is true, otherwise not. One example of the use of this technique is in stepping through 1 bit in a word, which is used to record pixel coverage for anti-aliasing.