float f = 0.7; if( f == 0.7 ) printf("equal"); else printf("not equal");
为什么输出not equal?
not equal
为什么会这样?
c c++ floating-point double-precision
我刚刚阅读了有关浮点值比较的声明
不能使用==或!=运算符比较浮点值.大多数浮点值没有精确的二进制表示,并且精度有限.
如果是这样,比较两个浮点值的最佳方法是什么?
.net c# floating-point comparison
floating-point ×2
.net ×1
c ×1
c# ×1
c++ ×1
comparison ×1
double-precision ×1