Author: Gerd Isenberg
Date: 10:53:19 07/11/03
Go up one level in this thread
Thanks Walter, the whole idea is based on de Buijn Sequences. The folding trick is great, unsigned folding safes the final "and". It even works with subtracting one from a single isolated bit. Regards, Gerd int lsz64_tbl[64] = { 0,31, 4,33,60,15,12,34, 61,25,51,10,56,20,22,35, 62,30, 3,54,52,24,42,19, 57,29, 2,44,47,28, 1,36, 63,32,59, 5, 6,50,55, 7, 16,53,13,41, 8,43,46,17, 26,58,49,14,11,40, 9,45, 21,48,39,23,18,38,37,27, }; int bitScanAndReset(BitBoard &bb) { BitBoard lsb = bb & -(__int64)bb; bb ^= lsb--; unsigned int foldedLSB = ((int) lsb) ^ ((int)(lsb>>32)); return lsz64_tbl[foldedLSB * 0x78291ACF >> 26]; }
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.