Decimal to other binary
Integer.tohexstring (10); Convert 10 to 16, return string type
Integer.tooctalstring (10); Convert 10 to octal, return string type
Integer.tobinarystring (10); Convert 10 to binary, return string type
Other decimal in binary
hexadecimal to decimal, for example: 0xFFFF
Integer.valueof ("FFFF", +). toString (); The ValueOf () method returns an integer type, calling ToString () to return a string
Integer.parseint ("FFFF", 16); Returns the INT basic data type
Integer.tostring (0xFFFF); The method can pass directly to the base data type that represents the hexadecimal number, and the method returns a string
octal decimal, for example: 017
Integer.valueof ("n", 8). toString (); The ValueOf () method returns an integer type, calling ToString () to return a string
Integer.parseint ("17", 8); Returns the INT basic data type
Integer.tostring (017); The method can pass directly to the base data type that represents the octal number, and the method returns a string
Binary to decimal, for example: 0101
Integer.valueof ("0101", 2). ToString (); The ValueOf () method returns an integer type, calling ToString () to return a string
Integer.parseint ("0101", 2); Returns the INT basic data type
Conversions between binary, octal, and hexadecimal can be converted to decimal and converted using decimal to multi-binary method
For example, turning hex 0xFF into binary
Integer.tobinarystring (integer.valueof ("FF", 16));
Or
Integer.tobinarystring (Integer.parseint ("FF", 16));
For input strings that represent hexadecimal, you need to intercept the number substring, and then use the valueof () or parseint () method to convert to decimal.
For example, enter 0xFF
String s = "0xFF";
Integer.valueof (S.substring (2,s.length ()), 16);
For the valueof method, it can be used for boxing of the base data type and for conversions between the decimal and the binary.
Conversion between binaries in Java