## Learn java base conversion supplementary learning

Sour grass 2021-01-14 14:55:45
learn java base conversion supplementary

###### Hexadecimal conversion :

Basics :

​ The number used in binary is :0/1

​ The number used in octal is :0/1/2/3/4/5/6/7

​ The decimal number is :0/1/2/3/4/5/6/7/8/9

​ The number used in hexadecimal is :0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15

​ -> because 10 The above is not a good indication ,10/11/12/13/14/15 Use letters to indicate a/b/c/d/e/f

​ -> So the hexadecimal number is expressed as :0/1/2/3/4/5/6/7/8/9/a/b/c/d/e/f

• Binary to decimal
`````` Take a chestnut : a=100110;
Then the decimal system is (2^0x0)+(2^1x1)+(2^2x1)+...+2^5x1=0+2+4+0+0+32=38
``````
• Octal to decimal
`````` Take a chestnut : a=345
Then the decimal system is (8^0x5)+(8^1x4)+(8^2x3)=5+32+64x3=229
``````
• Hexadecimal to decimal
`````` Take a chestnut : a=6af
Then the decimal system is (16^0x15)+(16^1x13)+(16^2x6)=15+16x13+16x16x6=1759
``````
• Convert decimal to hexadecimal `or` Convert decimal to octal `or` Convert decimal to binary
`````` Suppose the decimal number is : asdf/x //x It can be 16 or 8 or 2 It depends on why you convert
asdf/x=?....a;
if(?<x) be The result of the conversion is ?a
if(?>x) be Continue to divide
?/x=??....b;
if(?<x) be The result of the conversion is ??ba
if(?>x) be Continue to divide
??/x=???....c;
if(?<x) be The result of the conversion is ???cba
if(?>x) be Continue to divide
No more examples ; Through the decimal system as a medium , Can achieve four base arbitrary conversion ;
``````

Mengxin Xiaobai , It's possible that some aspects are not right , Welcome to correct ; We're going to be stronger together !

https://javamana.com/2021/01/20210114145444453x.html