Here you can find the source of shift(int a, int b)
public static int shift(int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { public static int shift(int a, int b) { if ((0 < b) && (b < 32)) { return a << b; } else if ((-32 < b) && (b < 0)) { return a >> (-b); } else if (b == 0) { return a; } else if (b >= 32) { return 0; } else {/*from www . j av a2 s . c o m*/ if (a > 0) { return 0; } else { return -1; } } } public static long shift(long a, int b) { if ((0 < b) && (b < 64)) { return a << b; } else if ((-64 < b) && (b < 0)) { return a >> (-b); } else if (b == 0) { return a; } else if (b >= 64) { return 0L; } else { if (a > 0) { return 0L; } else { return -1L; } } } }