Re: finding rightmost zero bit
- From: ttw@xxxxxxxxxxxxxxx
- Date: 29 Aug 2005 20:54:45 -0700
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.
.
- Follow-Ups:
- Re: finding rightmost zero bit
- From: glen herrmannsfeldt
- Re: finding rightmost zero bit
- References:
- [CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne
- [CHALLENGE] finding rightmost zero bit
- Prev by Date: Re: [CHALLENGE] finding rightmost zero bit
- Next by Date: Re: finding rightmost zero bit
- Previous by thread: Re: [CHALLENGE] finding rightmost zero bit
- Next by thread: Re: finding rightmost zero bit
- Index(es):