float a = 1148.53f;
float b = 624.83f;
System.out.println(a+b);
这里a+b输出的结果却是1773.3601
float a = 1148.53f;
float b = 624.83f;
System.out.println(a+b);
这里a+b输出的结果却是1773.3601
float a = 1148.53f;
float b = 624.83f;
DecimalFormat aAndb = new DecimalFormat( "#0.0 ");
System.out.println(aAndb.format(a+ b))
这个是精度问题!
希望对你有帮助
DecimalFormat c = new DecimalFormat( "#0.0 "); System.out.println(c.format(a+b));
需要指定精度~