Computer Chess Club Archives


Search

Terms

Messages

Subject: Counting Bits in BitBoard

Author: Nathan Thom

Date: 20:25:57 01/06/03


Hi all,

Does anyone have a super duper algorithm to count the number of set bits in a
64-bit number? In C, i have:

int CountBits(BitBoard *b) {
	int count=0;

	while (*b) {
		if (*b & (BitBoard)1) count++;
		*b >>= 1;
	}

	return count;
}

But im sure it could be much faster in assembler, i just dont know how.



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.