0x88: This approach fascinates me and I can only congratulate whoever came up with it (maybe one of my countless readers(!) can enlighten me).
It goes something like this.
Instead of having a 8x8 array, you make it a 16x8 array. Basically what happens is you'll get two boards next to each other (like the picture above). The left board represents the real board, and the right a dummy board used to check for off the board moves (amongst other things).
As you can see the first rank (a1..h1) have the index numbers 0..7. Then comes the dummy board with indexes 8..15. Then the second rank (a2..h2) with index 16..23, and then the dummy board again with indexes 24..31. Etc.
Now what does this do?
Well, it's not obvious at first, but the hexadecimal number 0x88 (136 in decimal form) is written 1000 1000 in binary form. As you can see the 4th and 8th bits are "set". If you play around a bit with this you can get a table:
Real board Dummy board Real..Dummy
Index Binary Index Binary Index Binary
0 0000 8 1000 117 0111 0101
1 0001 9 1001 118 0111 0110
2 0010 10 1010 119 0111 0111
3 0011 11 1011 .
4 0010 12 1100 120 0111 1000
5 0101 13 1101 .
6 0110 14 1110 180 1011 0100
7 0111 15 1111 222 1101 1110 etc.
if((aSquareIndex & 0x88) != 0)
System.out.println("Square not on the board");
0x88 1000 1000
1 0000 0001
First take all the zeros from 0x88
Result ?000 ?000
Now add the last two places from '1'
(since 0x88 has ones there)
Result 0000 0000 -> 0 (in decimal form)
0x88 1000 1000
14 0000 1110
First take all the zeros from 0x88
Result ?000 ?000
Now add the last two places from '14'
(since 0x88 has ones there)
Result 0000 1000 -> 8 (in decimal form)