Re: [CHALLENGE] finding rightmost zero bit



On 2005-08-29, Michel OLAGNON <molagnon@xxxxxxxxxxxxxxxxx> wrote:
>
>
> I claim the slowest

bartv@vonneumann:~/fortran$ ./time_findpos
huge(n) is 2147483647.
Enter first number: 1
Enter last number: 147483647
Total bits counted: 294967286
Bart1's method did it from 1 to 147483647 in 1.82 seconds.
Total bits counted: 294967286
Bart2's method did it from 1 to 147483647 in 1.88 seconds.
Total bits counted: 294967286
Bart3's method did it from 1 to 147483647 in 1.89 seconds.
Total bits counted: 294967286
Michel's method did it from 1 to 147483647 in 18.50 seconds.

*fwew*... that's indeed slow :-)

> but it's a one-liner:
>
> pos = nint (log (real(ieor(n,n+1)+1, kind=renough)) / log (2.0_renough))
>
>:-)

OK. Bonus-point for you :-)

Regards,
Bart

--
"Share what you know. Learn what you don't."
.



Relevant Pages