我对round()C中的功能有点困惑.
首先,男人说:
SYNOPSIS
#include <math.h>
double round(double x);
RETURN VALUE
These functions return the rounded integer value.
If x is integral, +0, -0, NaN, or infinite, x itself is returned.
Run Code Online (Sandbox Code Playgroud)
返回值是double/ float或int?
第二,我创建了一个第一轮的函数,然后转换为int.后来我的代码我用它作为比较双打的意思
int tointn(double in,int n)
{
int i = 0;
i = (int)round(in*pow(10,n));
return i;
}
Run Code Online (Sandbox Code Playgroud)
在我的测试中,这个功能显然不稳定.这里有冗余吗?嗯......我不只是寻找答案,而是更好地理解这个问题.