Excel RoundUp vs .NET Math.Round
c#, excel, math, rounding
Solution
double ROUNDUP( double number, int digits )
{
return Math.Ceiling(number * Math.Pow(10, digits)) / Math.Pow(10, digits);
}
Problem
in Excel, `=ROUNDUP(474.872126666666, 2)` -> 474.88 in .NET, ``` Math.Round(474.87212666666666666666666666667, 2, MidpointRounding.ToEven) // 474.87 Math.Round(474.87212666666666666666666666667, 2, MidpointRounding.AwayFromZero) // 474.87 ``` My client want Excel rounding result, is there any way I can get 474.88 in .NET? Thanks a lot