Reading about binary operations in Java i'm stack of next example :
10111011 & 00001000 = 00001000
00001000 is a 8 in decimal represenation
but when i try to execute the following code :
System.out.println("10111011 & 00001000 = " + (0b10111011 & 0b00001000));
System.out.println("10111011 & 00001000 = " + Integer.toString(0b10111011 & 0b00001000, 2));
i getting output :
10111011 & 00001000 = 8 // right!
10111011 & 00001000 = 1000 // not a 00001000!
So i have 2 questions :
1) Why when i make conjunction operations i have invalid result?(My mistake)
2) Why in output i have only part visible of bits? How i can see all of bits count? Why Integer.toString(value,radix) doesn't return full record as 00001000?