package com.thinker.common.test.test5;

/**
 *	
 *	将double转化成二进制输出
 *	
 **/
public class Test_5_2{

	public static void main(String[] args){
		double target = 11.5;
		String result = go(target);
		System.out.println(target+":\t"+result);
		System.out.println((byte)128);
	}
	public static String go(double num){
		double xiao = num % 1;
		int zheng = (new Double(num)).intValue();
		String x = com.thinker.test.test5.Test_5_2.go(xiao);
		StringBuffer result = new StringBuffer();
		result.append(zhengshu(zheng));
		result.append(x);
		return result.toString();

	}
	/**
	 *
	 *	将整数转化成二进制输出
	 *
	 **/
	public static StringBuffer zhengshu(int zheng){
		StringBuffer b = new StringBuffer();
		if(zheng > 0){
			int x = zheng % 2;
			StringBuffer f = zhengshu(zheng >> 1);
			b.append(f);
			if(x >= 1){
				b.append(1);
			}else{
				b.append(0);
			}
		}
		return b;
	}
}
