public static String binary2decimal(int decNum , int digit) { String binStr = ""; for(int i= digit-1;i>=0;i--) { binStr +=(decNum>>i)&1; } return binStr; }