System::Decimal::Round 方法

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

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

static Decimal System::Decimal::Round(const Decimal &d, int digits, MidpointRounding mode=MidpointRounding::ToEven)
参数类型描述
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)
参数类型描述
dconst Decimal&要四舍五入的值
modeMidpointRounding指定当 value 与两个最近的数字等距时如何执行四舍五入。

ReturnValue

d rounded to the nearest integral value

另见