Author: Bruce Moreland
Date: 09:50:11 03/11/98
Go up one level in this thread
On March 11, 1998 at 08:10:58, Mats Forsén wrote:
>class ChessBoard
> int8 Board[144] // piece+color present
88 uses a 128-element board. Each rank has 16 files, the leftmost 8 map
to a..h, while the rightmost 8 are not used for anything other than
place fillers.
> int16 Flags
The following is my semi-solicited opinion about sized integer types.
The coolest types in the world are "int" and "unsigned". Every compiler
writer will make sure that these types are sized appropriate to the
machine, they will use the machine's "natural" size. So if you just
need a number, and aren't too concerned about space, it is best to use
these.
If you are *really* concerned about space, or otherwise need some
specific number of bits, then you can use a sized type where you need
it, and allow the compiler to convert it for you everywhere else. For
instance, if you have an 8-bit flag word tucked away somewhere, you
shouldn't make a:
typedef char FLAGS;
just because you need 8 bits in this one place. This will result in
8-bit values spreading around all over your program, in function
paramebers, in automatic variables, in other structures where you aren't
concerned about space, etc. Maybe the compiler will recover for you
sometimes, but it can't always.
The reason sized types are disgusting is that if you use a lot of them,
they can slow you down on machines that aren't tolerant of words of some
particular size. For instance, 16-bit values suck on a Pentium 32-bit
application, and both 8-bit and 16-bit values suck on a 21164 Alpha.
bruce
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.