Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Binary question

Author: Robert Hyatt

Date: 15:07:19 10/19/00

Go up one level in this thread


On October 19, 2000 at 17:09:39, Severi Salminen wrote:

>Hi!
>
>Now I have my bitboard move generator online generating pawn and knight moves!
>It works, great! One question:
>
>How do I find n in a binary number 2^n? So f(1000b)=3? Now I just shift right:
>
>c=0;
>while(B>>++c) ;
>c--;
>
>Any ideas?
>
>Severi


Easiest answer is look at the crafty source.  Intel has instructions
BSF/BSR to do this.  Or you can do a table lookup.  Code for both
approaches is included in Crafty.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.