Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Determining location of LSB/MSB

Author: Bas Hamstra

Date: 07:57:15 02/10/04

Go up one level in this thread


On February 09, 2004 at 09:07:41, Gerd Isenberg wrote:

>On February 09, 2004 at 05:09:07, Renze Steenhuisen wrote:
>
>>
>>Hi there!
>>
>>does anyone know the fastest way to determine the lcoation of the Least/Most
>>Significant Bit, and to clear that bit?
>>
>>In my case the most important platforms (at the moment) are Pentium III and IV.
>>
>>Thanks!
>
>find lsb from CCC archives:
>
>http://chessprogramming.org/cccsearch/ccc.php?art_id=265616
>
>Walter Faxon's magic BitScan:
>http://chessprogramming.org/cccsearch/ccc.php?art_id=272378
>
>Matt Taylor's De Bruijn folding trick:
>http://chessprogramming.org/cccsearch/ccc.php?art_id=305965
>
>Gerd
>
>
>>
>>Renze

Gerd,

IMO the BSF instruction is still fastest. Don't test this in loops, in a
searching engine you get quite different results and BSF is in my case clearly
the winner, especially for the paltforms he mentiones, and besides he is not
talking 64 bit...


Bas.


int LastOne(unsigned int Number)

{  asm mov EAX, Number
   asm BSF EAX, EAX
}














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.