Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Quick bit extraction question

Author: Robert Hyatt

Date: 08:03:46 07/20/04

Go up one level in this thread


On July 20, 2004 at 08:19:25, Andrew Wagner wrote:

>Being the great genius that I am, it dawned on me the other day that creating a
>custom class to handle things like moves, which can be stored easily in
>integers, was not terribly efficient. So, let's say, for example, I'm storing
>the 'to' square for a move in the right-most (least-significant) 7 bits of an
>integer, the 'from' square in the next 7 least significant bits, and possibly
>other information in other (more significant) bits. What's the most efficient
>way to knock off extra, more significant bits? I want to do something like this:
>to = move MOD 128;
>from = (move>>7) MOD 128;
>
>...but not sure if that's most efficient. Thanks! Andrew


I doubt you can beat these:

#define From(x)   (x & 127)
#define To(x)     ((x >> 7) & 127)

etc...




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.