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
Hex values
-
- 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
"visualization"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
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...
![Smile :)](./images/smilies/icon_e_smile.gif)