public static void main(String[] strings){
float a = 2.0f;
int b = 0;
System.out.println(a/b);//Infinity
double c = 2;
double d = 1.1f;
System.out.println(c - d);//0.8999999761581421
float e = 2;
float f = 1.1f;
System.out.println(e - f);//0.9
float h = 2;
double i = 1.1f;
System.out.println(h - i);//0.8999999761581421
double j = 2;
float k = 1.1f;
System.out.println(j - k);//0.8999999761581421
BigDecimal b1 = new BigDecimal(j);
BigDecimal b2 = new BigDecimal(k);
System.out.println(b1);//2
System.out.println(b2);//1.10000002384185791015625
}
为什么使用double会损失精度?