Java类型Float&&Double

package study;

public class testFloatDouble {
public static void main(String[] args) {
float f = 0;
double d = 0;
for (int i = 0; i < 10; i++) {
f += 0.1;
d += 0.1;
}
System.out.println("float类型: f = " + f);
System.out.println("double类型: d = " + d);
}
}

 

结果如下:

float类型: f = 1.0000001
double类型: d = 0.9999999999999999

 

mark

posted @ 2016-04-15 10:09  宝山方圆  阅读(298)  评论(0)    收藏  举报