我不明白为什么浮点数值与双精度数值不同。从下面的例子中可以看出,对于相同的运算,float提供了不同的结果:
public class Test {
public static void main(String[] args) {
double a = 99999.8d;
double b = 99999.65d;
System.out.println(a + b);
float a2 = 99999.8f;
float b2 = 99999.65f;
System.out.println(a2 + b2);
}
}
输出:
199999.45
199999.44
你能解释一下浮点数和双精度浮点数之间的区别吗?