Hex values

Code, algorithms, languages, construction...
Post Reply
daz12
Posts: 16
Joined: Wed Feb 25, 2015 7:19 am

Hex values

Post by daz12 » Wed Nov 04, 2015 11:38 pm

I've seen chess code where bitboards are stored as hex strings. In my programming I've just stuck to storing them in decimal UInt64 format as it seems too much work converting to and from decimal to hex in C#. Is there any particular reason why you'd want to store bitboards in hex form despite conversion hassle?

Thanks

Daz

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Hex values

Post by hyatt » Thu Nov 05, 2015 12:12 am

daz12 wrote:I've seen chess code where bitboards are stored as hex strings. In my programming I've just stuck to storing them in decimal UInt64 format as it seems too much work converting to and from decimal to hex in C#. Is there any particular reason why you'd want to store bitboards in hex form despite conversion hassle?

Thanks

Daz
"visualization"

I can look at a hex number and instantly tell which squares are 1's and which are 0's and interpret/understand the pattern. A binary string shows the same info, but is far too long to handle. Decimal shows nothing at all.

for example, if you make bit 0 (LSB) square a1, and bit 63 (MSB) square h8, a value like 0xffff00000000ffffull is a pattern that could represent the occupied squares for the starting chess position (all squares on rank 1, 2, 7 and 8 are 1). What about this pattern: 4294901760?? All squares on rank 3 and rank 4 are occupied. Not so obvious... :)

Post Reply