The program binary to decimal conversion to java
The following is a simple program that berungsi for the conversion of binary numbers to decimal numbers with the programming language Java. valid for long ga, ga not have much further ado, straight, this source code:
public class conversion
{
public static void main (String [] args)
{
String bil = "110 111";
int [] arr_bil = new int [1000];
String [] st = new String [1000];
double result = 0, result = 0;
int a = 0;
char t;
for (int i = 0; i
{
t = bil.charAt (i);
st [i] = Character.toString (t);
}
for (int i = bil.length () -1; i> = 0; i-)
{
arr_bil [a] = Integer.parseInt (st [i]);
result = arr_bil [a] * (Math.pow (2, a));
result = result + result;
a + +;
}
{
int resultIn = (int) result;
System.out.println ("Numbers integer:" + bil);
System.out.println ("Numbers Decimal:" + resultIn);
}
}
}
and when the program running, it will display:
Integers: 110 111
Decimal Numbers: 55
Tidak ada komentar:
Posting Komentar