Author: Inmann Werner
Date: 13:06:29 09/17/99
Go up one level in this thread
On September 17, 1999 at 15:57:28, Inmann Werner wrote:
Too fast, too less accurate.... :(
changes below...
Hello.
Implementing bitboards I came to the old and known problem of finding the
number of a bit in the bitboard on Intel machines (32 bit).
Trying a little around this evening, I came to following routine. It is simple
in C, but looking at the assemmbler outcome, I do not know, if it is good.
How do you implement such a extreme critical routine?
Werner
***************
//Testroutine, not tuned but readable
//hope no silly bug in it :)
// hope also, the idea is clear
typedef unsigned __int64 BITBOARD;
long lookup1[100];
BITBOARD teil;
init_bits()
{
int i;
BITBOARD a,b,c;
long erg;
lookup1[0]=0;
a=1;
teil=67; /*## OK ##*/
for(i=1;i<64;i++)
{
erg=a%teil;
lookup1[erg]=i;
a=a<<1;
}
}
long findbit(BITBOARD x)
{
BITBOARD c;
long bitnr,erg;
c=x-(x&(x-1));
bitnr=c%teil;
erg=lookup1[bitnr];
return(erg);
}
******************************************
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.