fmod函数用于计算浮点数的取模运算(余数)。
但是在应用发现一个特例,可以尝试运行如下代码:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double result = fmod(1.0, 0.1);
cout << "1.0 % 0.1 = " << result1 << endl;
return 0;
}
此时结果是0.1。
有知道原因的大佬可以评论一下,感谢!