System::Decimal::Round 方法

Decimal::Round(const Decimal&, int, MidpointRounding) method

将指定的值四舍五入到具有指定小数位数的最近值。若指定的值恰好等距于两个最近的值,则通过参数指定函数的行为。

static Decimal System::Decimal::Round(const Decimal &d, int digits, MidpointRounding mode=MidpointRounding::ToEven)
ParameterType描述
dconst Decimal&要四舍五入的值
位数int四舍五入后值的小数位数
modeMidpointRounding指定当 value 与两个最近的数字等距时如何执行四舍五入。

ReturnValue

最接近 value 且具有指定位数的数字

另见

Decimal::Round(const Decimal&, MidpointRounding) method

将指定的值四舍五入到最近的整数。若指定的值恰好等距于两个最近的整数,则通过参数指定函数的行为。

static Decimal System::Decimal::Round(const Decimal &d, MidpointRounding mode=MidpointRounding::ToEven)
ParameterType描述
dconst Decimal&要四舍五入的值
modeMidpointRounding指定当 value 与两个最近的数字等距时如何执行四舍五入。

ReturnValue

d rounded to the nearest integral value

另见