相关疑难解决方法(0)

浮点加法和乘法是否相关?

当我添加三个浮点值并将它们与1进行比较时,我遇到了问题.

cout << ((0.7 + 0.2 + 0.1)==1)<<endl;     //output is 0
cout << ((0.7 + 0.1 + 0.2)==1)<<endl;     //output is 1
Run Code Online (Sandbox Code Playgroud)

为什么这些价值观会有所不同?

c++ floating-point

10
推荐指数
3
解决办法
5310
查看次数

标签 统计

c++ ×1

floating-point ×1