public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = 1010110;
System.out.println("the ith bit is " + ithBit(x, n));
}
public static int ithBit(int x, int n) {
int bitValue = (x & (1 << (n - 1))) != 0 ? 1 : 0;
return bitValue;
}
in number 1010110, its giving 4th bit=1,6th bit=1, 7th bit=0