1. 程式人生 > >JAVA_int型別資料精度高於float低於double

JAVA_int型別資料精度高於float低於double

public class Test{
public static void main(String[] args) {
 int a=Integer.MAX_VALUE;
int b=Integer.MAX_VALUE-15;
System.out.println(Integer.toHexString(a));//7fffffff
System.out.println(Integer.toHexString(b));//7ffffff0
System.out.println(a);//2147483647
System.out.println(b);//2147483632
System.out.println(a==b);//false

float fa=a;
float fb=b;
System.out.println(fa);//2.14748365E9
System.out.println(fb);//2.14748365E9
System.out.println(fa==fb);//true----->float的精度 比int型別進度低

double da=a;
double db=b;
System.out.println(da);//2.147483647E9
System.out.println(db);//2.147483632E9
System.out.println(da==db);//false------->double型別的精度比int型別高
}
}