protected int extractNumeral ( ) { int val = 0 ; final int topLeft = getTotalGridElements ( ) - gridWidth ; int shift = 0 ; // -2 because the top and bottom rows have 2 unusable bits (the first and last) for ( int i = 1 ; i < gridWidth - 1 ; i ++ ) { final int idx = topLeft + i ; val |= classified [ idx ] << shift ; //System.out.println("val |= classified[" + idx + "] << " + shift + ";"); shift ++ ; } // Don't do the first or last row, handled above and below - special cases for ( int ii = 1 ; ii < gridWidth - 1 ; ii ++ ) { for ( int i = 0 ; i < gridWidth ; i ++ ) { final int idx = getTotalGridElements ( ) - ( gridWidth * ( ii + 1 ) ) + i ; val |= classified [ idx ] << shift ; // System.out.println("val |= classified[" + idx + "] << " + shift + ";"); shift ++ ; } } // The last row for ( int i = 1 ; i < gridWidth - 1 ; i ++ ) { val |= classified [ i ] << shift ; //System.out.println("val |= classified[" + i + "] << " + shift + ";"); shift ++ ; } return val ; }
Extract the numerical value it encodes