Little-Endian or Big-Endian?

Code, algorithms, languages, construction...
Post Reply
MathAddict
Posts: 3
Joined: Mon Oct 26, 2015 2:24 pm
Real Name: Rian Neogi

Little-Endian or Big-Endian?

Post by MathAddict » Sun Dec 06, 2015 6:12 am

I was wondering if it is better to have little-endian representation of squares(a1=0,h8=63) or big-endian(h1=0,a8=63).
Currently I am using big-endian but I see that engines like Stockfish use little-endian so I was wondering if little-endian can be optimized to be faster.

thevinenator
Posts: 68
Joined: Tue Jun 02, 2015 11:02 pm
Real Name: Vince

Re: Little-Endian or Big-Endian?

Post by thevinenator » Sun Dec 06, 2015 1:41 pm

it is a matter of personal choice. i originally had my code in what you are calling "big endian", because it was easier to display boards on the console since the looping was going from 0 to 63 and the white piece were usually shown on the bottom of the board display. But as time went on, it got confusing when i examined or tried code from other developers who mostly use the "little endian" style. It wasn't too much work to switch and it all seems to be working now.
"An Engine's strength flows from the Search. But beware, pruning, extensions, reductions; the dark side of the Search are they. Once you start down the dark path, it will dominate and consume you, as it has to so many developers before.” -- Yoda

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: Little-Endian or Big-Endian?

Post by hyatt » Sun Dec 06, 2015 5:13 pm

The issue is bit numbering. Intel hardware (BSF/BSR) counts LSB as 0, MSB as 63. You should use that numbering scheme to avoid any sort of translation such as the 63 - N I did since I originally numbered the bits to match the Cray architecture. For simplicity I use a1=0, h1=7, a8=56, h8=63, makes move input and output translation a "direct process"...

Makes the bit boards a bit "backward" to visualize since rightmost bit = leftmost square, but then everything else is a direct map.

Post Reply