为什么.NET使用银行家的四舍五入作为缺省值?
decimal.Round
public static decimal RoundHalfUp(this decimal d, int decimals){ if (decimals < 0) { throw new ArgumentException("The decimals must be non-negative", "decimals"); } decimal multiplier = (decimal)Math.Pow(10, decimals); decimal number = d * multiplier; if (decimal.Truncate(number) < number) { number += 0.5m; } return decimal.Round(number) / multiplier;}
decimal.Round(2.5m, 0)
扬帆大鱼
至尊宝的传说
MMMHUHU