1.無條件進位
double s = 100;
int result = 0;
result = Convert.ToInt16(Math.Ceiling(s / 3));
int result = 0;
result = Convert.ToInt16(Math.Ceiling(s / 3));
2.無條件捨去
double s = 100;
int result = 0;
result =Convert.ToInt16( Math.Floor(s / 3));
int result = 0;
result =Convert.ToInt16( Math.Floor(s / 3));
3.四捨五入
double s = 110;
double result = 0;
result = Math.Round((s / 3), 2, MidpointRounding.AwayFromZero);
double result = 0;
result = Math.Round((s / 3), 2, MidpointRounding.AwayFromZero);
沒有留言:
張貼留言