Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: mask of highest bit - additional notes

Author: Chan Rasjid

Date: 22:11:06 09/21/05

Go up one level in this thread


On September 21, 2005 at 23:31:56, Andrew Shapira wrote:

>Hi.  I'm interested mainly in ideas - the details of these things can be worked
>out later.  So being off by 1 somewhere does not really concern me right now.  I
>have not heard anything about what I asked about - which is, how, in O(1) time,
>do you find the mask of the highest bit using only C's + - ^ ~ << >> operators?
>I thought this was clear in my original post, but maybe somehow it wasn't.  Or
>maybe you didn't read it.  The whole point is to do it quickly and portably.  If
>I wanted to do it in an unportable way I would use machine instructions for
>finding the highest significant bit, or something similar.  If I wanted to do it
>relatively slowly, say in O(lg N) time and not O(1) time, I would do it using
>the >>1, >>2, >>4 method.  It is of some interest to do this using * or /
>although that is not the main question here.  And I am definitely not interested
>at the moment in things that will only work on one machine.

What you ask is what all the chess programmers using bitboards need badly.
I think the possibility is slim as none in CCC ever mentioned any success so
Gerd had to get alternative.

http://graphics.stanford.edu/~seander/bithacks.html
This link had all the things about log base 2 etc.. but I think 3- 7 operations
for 1 byte w/o conditionsals.

BTW if you are in the US you cannot use :-
#define        ABS_INTEGER(x)  ((+1|(x>>SIZE_OF_INT_LESS1))*x)
A Russian got the US patent.


Rasjid





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.