#include<stdio.h> int main(){ double i=0; double k=10; for(int j=0;j<100;j++){ i+=0.1; } printf("%d ",i!=k); printf("%lf ",i); printf("%lf ",k); return 0; }
1 10.000000 10.000000 -------------------------------- Process exited after 0.1828 seconds with return value 0 请按任意键继续. . .
结果可见多次运算的浮点数i已经和浮点数k不等
所以要多次运算浮点数时,尽量使用"<" ">"减少使用“=”
具体参考网友的博客https://blog.csdn.net/fanxueya1322/article/details/86580954