Here you can find the source of shift(int direction, long sq, int delta)
public static long shift(int direction, long sq, int delta)
//package com.java2s; //License from project: LGPL public class Main { private static long[] SHIFT_MASKS = new long[8]; private static final int[] DIRECTION_SHIFTS = new int[] { 8, 9, 1, -7, -8, -9, -1, 7 }; public static long shift(int direction, long sq, int delta) { long result = sq; for (int i = 0; i < delta; i++) { result = shift(direction, result); }/*w ww .ja v a2 s . c o m*/ return result; } public static long shift(int direction, long sq) { int shift = DIRECTION_SHIFTS[direction]; if (shift < 0) return (sq >>> (-shift)) & SHIFT_MASKS[direction]; else return (sq << shift) & SHIFT_MASKS[direction]; } }