Re: finding rightmost zero bit



For a chess-playing program I found the following the fastest. First,
check if N>2**32 then check against the 2**16 and 3*2**16; continue
down to 8 bits. (Using a binary search this takes only 3 tests.) This
gives a partial answer. The previous answer is then completed by taking
the unknown byte and using a table lookup: 00000000=1, 000000001=1,
00000010=2,00000011=1, etc. A similar method was fastest for leading 1
bits.

.