/**
* 基本数据类型之浮点类型
*/
public class DataTypeDemo2 {
public static void main(String[] args) {
double d1 = 3;
System.out.println(d1);//3.0
double d2 = 2.4;
d1 = d1 - d2;
System.out.println(d1);//0.6000000000000001
float f1 = 3.0F;//声明一个float类型变量需要加后缀F
float f2 = 2.4F;
f1 = f1 - f2;
System.out.println(f1);//0.5999999
System.out.println(5/2);//
/*
* 低精度的数据类型与高精度做运算时,返回结果都
* 是高精度的值
*/
System.out.println(5.0/2);//2.5
double max = Double.MAX_VALUE;
System.out.println(max*max);//Infinity 无限大
double sqrt = Math.sqrt(-3);
System.out.println(sqrt);//NaN(Not A Number)
}
}