C# decimal take ceiling 2

后端 未结 4 1571
半阙折子戏
半阙折子戏 2020-12-02 01:00

I want to round my decimal value like 2.2222 to 2.23. When I use round,

decimal a = Math.Round((decimal)2.222, 2);

When I use ceiling, it c

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 01:36

    try something like

    decimal c = Math.Ceiling((decimal)2.222*100)/100;
    

    but it fails if your value is 2.22

提交回复
热议问题