One, the conversion of the binary into decimal
int Integer.parseint (String s,int radix); Method use:
parseint ("0", 10) returns 0
parseint ("473", 10) returns 473
parseint ("0", 10) returns 0
parseint ("-ff", 16) return-255
parseint ("1100110", 2) returns 102
parseint ("2147483647", 10) returns 2147483647
parseint ("2147483648", 10) return-2147483648
parseint ("2147483648", 10) throws NumberFormatException
parseint ("99", 8) throws NumberFormatException
parseint ("Kona", 10) throws NumberFormatException
parseint ("Kona", 27) return 411787
Parameters:
S-String containing the integer representation to parse
Radix-the cardinality used when analyzing S.
Return:
An integer that is represented by a string parameter of the specified cardinality.
Thrown:
NumberFormatException-If String does not contain an int that can be parsed.
It can be understood that the second parameter represents some kind of a binary of the first parameter, such as:
Integer.parseint ("0101", 2);//indicates that the string is a binary and then converts it to a 10-binary int type to return
Integer integer.valueof (Strings, int radix), method use consistent.
Two or 10 binary conversion to other binary:
String Integer. tobinarystring (int i);
Returns the string form of an integer parameter as a binary unsigned integer.
Integer.tobinarystring (10);//return: 1010
String Integer. tooctalstring (int i);
Returns the string form of an integer parameter as an octal unsigned integer.
Integer.tooctalstring (10);//return: 12
String Integer. tohexstring (int i);
Returns a string form of an integer argument as an unsigned 16-based integer.
Integer.tohexstring (10);//return: A
(You can transition between these two methods if you want to convert between other binaries )
Reciprocal conversions between decimal and other binary