public class Ten Change Two {
public static void main(String[] args){
System.out.println(“请输入一个十进制的整数:”);
Scanner sc = new
Scanner(System.in);
double d = sc.nextDouble();
int z = (int)d;
double x = d-z;
long j = 1;
long sum = 0;
for(int i = z;i > 0;i = i/2){
sum += i%2j;
j= 10;
}
double sumx = 0.0,k=0.1;
int h =1;
for(;;k/10){
x = (x-(int)x)2;
sumx += (int)xk;
h++;
if(x - (int)x == 0.0)
break;
}
System.out.println(“转换为二进制的数值为:”+ (sum + sumx));