double nums = .123;//0.123 // 科学计数法 System.out.println(5.12e2);//512 System.out.println(5.12E-2);//0.0512 //浮点数陷阱: double num11 = 2.7; double num12 = 8.1 / 3; System.out.println(num12);//接近2.7的小数 System.out.println(num11); //对于运算结果是小数的值,不能直接进行判断 //要用两个数的差值的绝对值,在一定精度范围内判断 // if(num12==num11){ // System.out.println("num11 == num12 相等"); // } if (Math.abs(num11-num12) < 0.00001 ){ System.out.println("差值很小,视为相等"); }
标签:浮点数,num11,System,num12,使用,println,out From: https://www.cnblogs.com/Icy01/p/17304701.html