圓()在C+中浮動我需要一個簡單的浮點舍入函數(shù),因此:double round(double);round(0.1) = 0round(-0.1) = 0round(-0.9) = -1我能找到ceil()和floor()在數(shù)學(xué)里.但是.round().它是以另一個名稱出現(xiàn)在標(biāo)準(zhǔn)C+庫中,還是丟失了?
3 回答

BIG陽
TA貢獻(xiàn)1859條經(jīng)驗 獲得超6個贊
#include <boost/math/special_functions/round.hpp>double a = boost::math::round(1.5); // Yields 2.0int b = boost::math::iround(1.5); // Yields 2 as an integer
編輯std::round
, std::lround
std::llround
.
- 3 回答
- 0 關(guān)注
- 556 瀏覽
添加回答
舉報
0/150
提交
取消