我创建了一个空白的Win32 C++项目。即使我包括math.h或cmath.h库,编译器仍然会为圆函数提供未定义的C3861错误。
我试过以下几种方法
1. adding the /TC compile as C++ and using cmath
2. adding the include _MATH_DEFINES_DEFINED 发布于 2015-06-11 09:15:41
Visual 2012 (MSVC11.0)并不严格遵循C++11,因此它可能没有std::圆形。
使用
inline double round(double value) { return value < 0 ? -std::floor(0.5 - value) : std::floor(0.5 + value); }
// analogously for float发布于 2015-06-11 09:10:10
你是想转成整数吗?
std::round()不返回int值,
相反,试着:
int a = int(std::floor(var + 0.5));有关更多解释:http://en.cppreference.com/w/cpp/numeric/math/round
https://stackoverflow.com/questions/30776273
复制相似问题