Java Fundamentals-Binary conversions
Yun Zhengjie
Copyright Notice: Original works, declined reprint! Otherwise, the legal liability will be investigated.
I. Common binary in Java programs
1> decimal, consisting of 10 numbers "0123456789", every ten into one;
2> binary, consisting of 2 numbers "01", every two in one, beginning with "0b";
3>. Eight binary, composed of "01234567" of the 8 numbers, every eight into one, with the number "0" beginning;
4>. 16 binary, composed of "0123456789abcdef" 16 numbers, every 16 into one, with "0x" start;
Note that in the CPU, memory, the data in the hard disk are "0" and "1", but in the program, we can use any of the above in the system yo.
Two. Conversion of the binary to each other
1>. decimal to Binary binary
For 2, reverse output.
2>. Decimal to Octal
8 Full, Reverse output
3>. Decimal to hexadecimal
For 16, reverse output
4>.
5>.
6>.
Java Fundamentals-Binary conversions