Wednesday, September 1, 2010

Program binary to decimal conversion java

he following is a simple program that used for conversion of binary numbers to decimal numbers with the Java programming language. no need further ado, straight, it is the source code:


public class conversion
(
public static void main (String [] args)
(
String car = "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 + +;
)

(
resultIn int = (int) result;
System.out.println ("Numbers integer:" + car);
System.out.println ("Decimal Numbers:" + resultIn);
)
)
)

and when the program is running on, it will display:
Integer: 110 111
Decimal Numbers: 55
source : www.inilahjalanku.com