Computer Chess Club Archives


Search

Terms

Messages

Subject: getting the least significant bit.. optimizing java :]

Author: Johan Wessfeldt

Date: 09:38:40 08/13/03


Im developing a chess engine in java and Im done with the move-generation.
Ive run a couple of tests and so far so good. No perf-test failures yet! :]

Ive discovered my Least significant Bit method is really slowing me down tho..

The best Ive come up with so far goes like this:

private int lsb(long a){
for(int i=63;i>0;i--){
 if( (a & mask[i] ) == mask[i] ){
 return i;      }
}
return 0;
}

where mask[] is a vector of all the combinations.. like mask[0] = 0001, mask[1]
= 00010, mask[3] = 00100 ... and so on.

Ive tried some well known methods but with no results since Java's long(64 bits)
datatype is signed. It messes up the bits..

(All datatypes in Java are signed)

Anyone have any suggesitons on how to optimize this method?



This page took 0.01 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.