Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: How can you get the number of a bit which is set in a bitboard ?

Author: Robert Hyatt

Date: 18:02:15 08/19/99

Go up one level in this thread


On August 19, 1999 at 18:59:16, Dann Corbit wrote:

>It's hard to guess what you are after, but there are lots of ways to manipulate
>bits in an object.  Assuming that you have a char pointer to an object, and that
>you do not go beyond the total bit counts for that object you can use a
>technique like this:
>#define bitset( buf, bit ) ( buf[(bit) >> 3] |= ( 1 << ( (bit) & 7 )))
>#define bitclr( buf, bit ) ( buf[(bit) >> 3] &= ~( 1 << ( (bit) & 7 )))
>#define bittog( buf, bit ) ( buf[(bit) >> 3] ^= ( 1 << ( (bit) & 7 )))
>#define bitget( buf, bit ) ((( buf[(bit) >> 3] >> ( (bit) & 7 )) & 1 ))


Those are the easy ones..  he is trying to find the number of the bit that
is set (ie the FirstOne()/LastOne() functions in Crafty).  That is harder..



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.