浮点数扩展
浮点数扩展
浮点数能表现的字长是有限的,也是离散的,浮点数存在舍入误差
很多数字没法精确表示,所以只能是一个大约数
public class Demo02 {
public static void main(String[] args) {
// 浮点数扩展
float f = 0.1f; // 0.1
double d = 1.0/10; // 0.1
System.out.println(f==d); // false
float d1 = 2313131313131313131f;
float d2 = d1+1;
System.out.println(d1==d2); // true
/*
浮点数能表现的字长是有限的,也是离散的,浮点数存在舍入误差
很多数字没法精确表示,所以只能是一个大约数
*/
}
}
唯有努力,人生没有白走的路,每一步都算数

浙公网安备 33010602011771号