Java语言:求 写一个输入整数(如123456789)转换为二进制的程序,如输入32则输出1000000



public class Main {
public static void main(String[] args) {
int integer = 127; //十进制数
String binary = Integer.toBinaryString(integer);
System.out.println("Binary value of " + integer + " is " + binary + ".");
int original = Integer.parseInt(binary, 2);
System.out.println("Integer value of binary '" + binary + "' is " + original + ".");
}
}



Copyright © 2009-2011 All Rights Reserved.