losing the leading zero in binary values
Hi all,
This is my first posting, think itâs great to have a community based around a book - really helpful. Iâm currently creating some examples of bitwise operations from p64, and Iâve just noticed that Iâm losing the leadnig zero of a binary value ( e.g.
decimal 1 (expecting to see bin of 0001) is manifesting as 1
decimal 16 (expecting to see bin of 00010000) is manifesting as 10000
below is an example if you want to compile it
_______________________________
import static java.lang.Integer.*;
public class BitExample {
public static void main(String[] args) {
System.out.println(
toBinaryString(0x1) + '\n' +
toBinaryString(0x16) + '\n' +
toBinaryString(0x6a) + '\n' +
toBinaryString(0x80)
);
}
}
_______________________________
I can see Iâm missing something, but not sure what. Can you help?
Many Thanks
Giles
|