I'm trying to check whether or not a number has the second bit flag (ie 0000 0010). My code is as follows:
int flags = Integer.parseInt(fields[1]);
String strflags = Integer.toBinaryString(flags);
flags = Integer.parseInt(strflags);
int secondBitTest = Integer.parseInt("00000010", 2);
if((flags & secondBitTest) == 2) {
System.out.println("YES");
}
However I think I might be doing this wrong, since when I try to input 147 nothing is returned.