Author: Dann Corbit
Date: 23:17:52 06/17/02
Go up one level in this thread
#ifdef _MSC_VER
typedef unsigned __int64 Bitboard;
#define LLEXT ui64
#define UIFMT "%I64u"
#else
typedef unsigned long long Bitboard;
#define LLEXT llu
#define UIFMT "%llu"
#endif
#define cat(x, y) x ## y
#define xcat(x, y) cat(x, y)
Bitboard p2[] = {
xcat(0x1, LLEXT),
xcat(0x2, LLEXT),
xcat(0x4, LLEXT),
xcat(0x8, LLEXT),
xcat(0x10, LLEXT),
xcat(0x20, LLEXT),
xcat(0x40, LLEXT),
xcat(0x80, LLEXT),
xcat(0x100, LLEXT),
xcat(0x200, LLEXT),
xcat(0x400, LLEXT),
xcat(0x800, LLEXT),
xcat(0x1000, LLEXT),
xcat(0x2000, LLEXT),
xcat(0x4000, LLEXT),
xcat(0x8000, LLEXT),
xcat(0x10000, LLEXT),
xcat(0x20000, LLEXT),
xcat(0x40000, LLEXT),
xcat(0x80000, LLEXT),
xcat(0x100000, LLEXT),
xcat(0x200000, LLEXT),
xcat(0x400000, LLEXT),
xcat(0x800000, LLEXT),
xcat(0x1000000, LLEXT),
xcat(0x2000000, LLEXT),
xcat(0x4000000, LLEXT),
xcat(0x8000000, LLEXT),
xcat(0x10000000, LLEXT),
xcat(0x20000000, LLEXT),
xcat(0x40000000, LLEXT),
xcat(0x80000000, LLEXT),
xcat(0x100000000, LLEXT),
xcat(0x200000000, LLEXT),
xcat(0x400000000, LLEXT),
xcat(0x800000000, LLEXT),
xcat(0x1000000000, LLEXT),
xcat(0x2000000000, LLEXT),
xcat(0x4000000000, LLEXT),
xcat(0x8000000000, LLEXT),
xcat(0x10000000000, LLEXT),
xcat(0x20000000000, LLEXT),
xcat(0x40000000000, LLEXT),
xcat(0x80000000000, LLEXT),
xcat(0x100000000000, LLEXT),
xcat(0x200000000000, LLEXT),
xcat(0x400000000000, LLEXT),
xcat(0x800000000000, LLEXT),
xcat(0x1000000000000, LLEXT),
xcat(0x2000000000000, LLEXT),
xcat(0x4000000000000, LLEXT),
xcat(0x8000000000000, LLEXT),
xcat(0x10000000000000, LLEXT),
xcat(0x20000000000000, LLEXT),
xcat(0x40000000000000, LLEXT),
xcat(0x80000000000000, LLEXT),
xcat(0x100000000000000, LLEXT),
xcat(0x200000000000000, LLEXT),
xcat(0x400000000000000, LLEXT),
xcat(0x800000000000000, LLEXT),
xcat(0x1000000000000000, LLEXT),
xcat(0x2000000000000000, LLEXT),
xcat(0x4000000000000000, LLEXT),
xcat(0x8000000000000000, LLEXT)
};
Bitboard p2b(unsigned bit)
{
const Bitboard bb1 = 1;
return bb1 << bit;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
Bitboard b0,
b1;
unsigned u;
int i;
srand((unsigned) time(NULL));
for (i = 0; i < 1000000; i++) {
u = (unsigned) (rand() / (RAND_MAX / 63 + 1));
b0 = p2[u];
b1 = p2b(u);
}
printf("u=%u, b0=" UIFMT ", b1=" UIFMT "\n", u, b0, b1);
b0 = p2[0];
b1 = p2b(0);
printf("u=0, b0=" UIFMT ", b1=" UIFMT "\n", b0, b1);
b0 = p2[63];
b1 = p2b(63);
printf("u=63, b0=" UIFMT ", b1=" UIFMT "\n", b0, b1);
return 0;
}
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.