Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Best way to extract n from 2^n (n=0..63)?

Author: Robert Hyatt

Date: 06:57:27 09/13/99

Go up one level in this thread


On September 13, 1999 at 04:48:40, stefan wrote:

>Thank you
>stefan plenkner

assumption:

  number _is_ an exact power of 2.

then simply use the BSF function (ie FirstOne() in Crafty Source) to find
the only 1 bit set (since this is an exact power of 2).  If the left-most bit
is set, you get 0.  If the rightmost bit is set, you get 63.  Just invert this
with 63-N and you are done...



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.