/** * Rotate a long to the left, cyclic with length len * * @param v Bits * @param shift Shift value * @param len Length * @return cycled bit set */ public static long cycleLeftC(long v, int shift, int len) { if(shift == 0) { return v; } if(shift < 0) { return cycleRightC(v, -shift, len); } final long ones = (1 << len) - 1; return (((v) << (shift)) | ((v) >>> ((len) - (shift)))) & ones; }