Re: [CHALLENGE] finding rightmost zero bit
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Tue, 30 Aug 2005 17:14:11 GMT
Michel OLAGNON wrote:
I claim the slowest but it's a one-liner:
pos = nint (log (real(ieor(n,n+1)+1, kind=renough)) / log (2.0_renough))
:-)
How about this for the fastest untested one-liner ;>
pos = count(iand(not(n),ieor(n,n+1))> [0,1,2,4,8,16,32,64] )
It seemed to work for the numbers up to 32 that I could mentally convert into binary. And, it's not only easily extensible, but it's obvious how it works!
*** Hendrickson
.
- Follow-Ups:
- Re: [CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne
- Re: [CHALLENGE] finding rightmost zero bit
- References:
- [CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne
- Re: [CHALLENGE] finding rightmost zero bit
- From: Michel OLAGNON
- [CHALLENGE] finding rightmost zero bit
- Prev by Date: Re: Getting a program to inform you when it's done
- Next by Date: Re: Getting a program to inform you when it's done
- Previous by thread: Re: [CHALLENGE] finding rightmost zero bit
- Next by thread: Re: [CHALLENGE] finding rightmost zero bit
- Index(es):