验证中...
Languages: C/C++
Categories: 常用工具包
Latest update 2019-02-14 04:52
.cpp
Raw Copy
struct runningRounding
{
runningRounding(int &&decimal) : m_decimal(move(decimal)), m_rest(0) {}
double operator()(const double &value)
{
const double &ret = static_cast<int>((value + m_rest) * pow(10, m_decimal) + 0.5) / pow(10, m_decimal);
m_rest += (value - ret);
return ret;
}
private:
int &&m_decimal;
double m_rest;
};

Comment list( 0 )

You need to Sign in for post a comment

Help Search

183227_9af5e6a8_1826025 111910_4d91f001_1826025