Solution (source code)

= Solution

Choose bit zero of each integer to represent the leftmost cell in its group of 32 columns. Then use a quotient to choose the word and a remainder to choose the bit:
``
java
static boolean getBit(int[][] board, int i, int j) {
    return ((board[i][j >>> 5] >>> (j & 31)) & 1) != 0;
}
``
For valid $0\leq i,j<1024$, `j >>> 5` is $\lfloor j/32\rfloor$ and ranges from zero to 31. The <bit mask> `j & 31` is the offset $j\bmod32$. The logical right <bit shift> brings the desired bit to position zero; the final mask selects only that bit. \b[Even bit 31 of a negative stored word is extracted correctly], because `>>>` inserts zeros. A different convention, with the leftmost cell in the most significant bit, would instead shift by `31 - (j & 31)` and must be used consistently.