差异dev-cpp和Microsoft Visual C ++ math.h

时间:2011-11-29 19:24:30

标签: c++ visual-c++ rounding dev-c++ math.h

几天前,我参与了VC ++项目。我发现,VC ++中的math.h与dev-cpp math.h有很大的不同。特别是它的循环函数,在Visual C ++ math.h中不存在,但包含在dev-cpp math.h中。

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

感谢大家的回复。

1 个答案:

答案 0 :(得分:4)

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

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}