call of overloaded 'round
(&float)' is ambiguous
解决:
#include <boost/math/special_functions/round.hpp>
double a = boost::math::round(1.5); // Yields 2.0
int b = boost::math::iround(1.5); // Yields 2 as an integer
For more information, see the Boost documentation.
如果你用的 C++11, 你可以用这些组件:
std::round
, std::lround
, and std::llround
.
参考:http://stackoverflow.com/questions/485525/round-for-float-in-c