C# 四捨五入,無條件進位及無條件捨去寫法
一.四捨五入
1 double s = 110;
2 double result = System.Math.Round(1.235 , 2, MidpointRounding.AwayFromZero);
二.無條件進位
1 double s = 100;
2 double result = Convert.ToInt16(Math.Ceiling(s / 3));
三.無條件捨去
1 double s = 100;
2 double result = Convert.ToInt16( Math.Floor(s / 3));
文章標籤
全站熱搜
