- 1). Obtain the value represented in binary, and store the binary representation in a string. This sample code stores the binary representation of 192:
String binNumber = "11000000"; - 2). Convert the string to an integer using the built-in parseInt() method, as in this sample code:
int number = Integer.parseInt(binNumber,2); - 3). Generate the decimal representation of the number, as in this sample code:
String decNumber = String.format("%d",number);
For the example, the string "decNumber" will contain the value "192."
SHARE