java的小数比较反例

double num = 0.3;
System.out.println(num);
System.out.println(num - 0.2);
System.out.println(num - 0.2 == 0.1);

结果为

0.3
0.09999999999999998
false

 

posted @ 2017-09-05 11:49  理舞  阅读(298)  评论(0编辑  收藏  举报