3

几天前,我在 VC++ 中工作。我发现,VC++ 中的 math.h 与 dev-cpp math.h 有很大不同。特别是它的 round 函数,它不存在于 Visual C++ math.h 中,但包含在 dev-cpp math.h 中。

现在我想问一下,这是否是由myngw中的dev-cpp根引起的?或者它是否是不同的标准(ISO)

感谢大家的回复。

4

1 回答 1

4

round()是 C99 标准的一部分,Visual Studio 不完全支持。但是您可以轻松编写自己的实现:

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
于 2011-11-30T22:38:44.763 回答