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));
  

文章標籤
全站熱搜
創作者介紹
創作者 hsiung03 的頭像
hsiung03

hsiung.博格 ERP軟體

hsiung03 發表在 痞客邦 留言(0) 人氣(193)