Author: Vincent Diepeveen
Date: 08:28:48 02/10/04
Go up one level in this thread
On February 10, 2004 at 10:57:15, Bas Hamstra wrote:
>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.
It depends upon which CPU you use Bas.
In diep i'm using a simple table lookup for several years already; later i found
out that Nalimov had posted similar code here for 64 bits bitboards.
But well i'm not 64 bits bitboards so in 32 bits it's a lot easier :)
The reasons why i'm not using BSF has however a different cause than the reason
why Nalimov posted it without BSF here. I simply want to avoid inline assembly
wherever possible.
For me that is a convincing argument favouring Eugene's code :)
>
>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.