Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: For compiler gurus about Bit fields

Author: Gerd Isenberg

Date: 01:17:09 11/13/04

Go up one level in this thread


On November 12, 2004 at 09:18:09, Peter Fendrich wrote:

>Will C++ compilers (especially .NET) handle bit fields with decent performance?
>It is very tempting to use them in hash tables for instance.
>Something like this:
>
>struct Hash
>{
>   unsigned KeyPart    : 48;   // 32+16
>   unsigned Eval       : 16;
>   unsigned Flag       :  2;   // FH, FL, Inside
>   unsigned FrPiece    :  4;   // Move
>   unsigned Fr         :  6;   // Move
>   unsigned To         :  6;   // Move
>   unsigned Threat     :  1;
>   unsigned Depth      : 10;
>   unsigned Generation :  3;
>} hash;
>
>hash.KeyPart = HashKey;
>etc...
>
>/Peter

Seems that lot programmers don't trust some compilers bitfield abilities and do
bitfrickling by theirself - specially if sign extension with signed int is
involved - or possible signed/unsigned overflows. I use bitfields here and
there, but hide the implementation details with setter- and getter-inlined
functions or macros.

Gerd



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.