四舍五入,默认保留2位小数
程序员文章站
2024-01-10 14:28:34
...
/// <summary>
/// 四舍五入,默认保留2位小数
/// </summary>
/// <param name="value">值</param>
/// <param name="decimals">保留小数位数,默认2</param>
/// <returns></returns>
public static decimal RoundPoint(decimal? value, int decimals = 2)
{
var vResult = value.GetValueOrDefault(0);
return Math.Round(vResult, decimals);
}