C#四舍六入五留双
/// <summary> /// 小数保留位数处理 /// </summary> /// <param name="value">值</param> /// <param name="digitNum">保留位数</param> /// <param name="MR">数学舍入方法</param> /// <returns></returns> public static decimal MathRound(decimal value, int digitNum,MidpointRounding MR) { return Math.Round(value, digitNum, MR); } /// <summary> /// 小数保留位数处理(默认四舍六入五留双) /// </summary> /// <param name="value">值</param> /// <param name="digitNum">保留位数</param> /// <returns></returns> public static double MathRound(double value, int digitNum) { return (double)MathRound((decimal)value, digitNum, MidpointRounding.ToEven);//四舍六入五留双 }