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 }
---- 动动手指关注我!或许下次你又能在我这里找到你需要的答案!ZZZZW与你一起学习,一起进步!
原文地址:https://www.cnblogs.com/zzzzw/p/5105917.html