I am not able to understand why in the following program it is mentioned in my book:
The value of ~a is ANDed with 0x0f (0000 1111) in binary in order to reduce its value to less than 16, so it can be printed by use of the binary array.
class bitLogic
{
public static void main(String args[])
{
String binary[] = { "0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111" };
int a=3;
int b=6;
int c=a | b;
int d=a & b;
int e=a ^ b;
int f=(~a&b) | (a&~b);
int g=~a& 0x0f;
System.out.println(" a = "+ binary[a]);
System.out.println(" b = "+ binary[b]);
System.out.println(" a|b = "+ binary[c]);
System.out.println(" a&b = "+ binary[d]);
System.out.println(" a^b = "+ binary[e]);
System.out.println("(~a&b)|(a&~b)= "+ binary[f]);
System.out.println(" ~a = "+ binary[g]);
}
}
Could someone please tell me how to we come to know which binary number representations like 0x0f , 0x0f1 , 0x0ff..etc. represent.