Computer Chess Club Archives




Subject: Re: is the

Author: Robert Hyatt

Date: 12:57:37 08/04/98

Go up one level in this thread

On August 04, 1998 at 12:15:45, Bruce Moreland wrote:

>On August 04, 1998 at 11:34:15, Robert Hyatt wrote:
>>The most direct way of probing a table of N words, where N is not an
>>exact power of to is this:
>>address=key % N;
>>where % is the "modulo" operator in C.  if N is an exact power of 2,
>>you can replace this by
>>address=key>>(log2 N);
>The compiler should know what to do if you use a constant value of N.  If you
>don't, you can subtract one and complement it someplace ( N = ~(N-1) ), and then
>just say
>address = key & N
>This is splitting hairs though.

I do the latter, because my hash size is dynamic.  But key&mask only works
if this is a power of two, of course, which is why the % operator is needed
for oddball hash sizes.

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.