Computer Chess Club Archives




Subject: Re: is the

Author: Bruce Moreland

Date: 09:15:45 08/04/98

Go up one level in this thread

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.


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.