Fork me on GitHub

float保留7位double保留15位之后的数字四舍五进

public class $66 {

    public static void main(String agrs[])
    {
        float a=(float) 1.123456789;//8位
        System.out.println(a);//1.1234568
    

        double aa=10.123456789123456789;//17位
        System.out.println(aa);//    10.123456789123457
    }
}

 

 1 public class $66 {
 2 
 3     public static void main(String agrs[])
 4     {
 5         float a=(float) 12.123456789;//8位
 6         System.out.println(a);//12.123457
 7     
 8 
 9         double aa=101.123456789123456789;//17位
10         System.out.println(aa);//    10.123456789123457
11     }
12 }

 

posted @ 2016-01-06 15:53  ZZZZW  阅读(380)  评论(0编辑  收藏  举报
AmazingCounters.com