C# 进一取整
C#:
// "/"号现在整形运算是取整,浮点运算时为除法运算
Console.WriteLine("(56/10):{0}", 56 / 10);//5
Console.WriteLine("(56/10):{0}", 56.00 / 10);//5.6
Console.WriteLine("(56/10):{0}", 56 / 10.00);//5.6
//取余
Console.WriteLine("(54.0%10.0):{0}", 54.0 % 10.0);//4
Console.WriteLine("(56.0%10.0):{0}", 56.0 % 10.0);//6
//Math.Ceiling 进一取整
Console.WriteLine("Math.Celling(54.0/10.0):{0}", Math.Ceiling(54.0 / 10.0));//6
Console.WriteLine("Math.Celling(56.0/10.0):{0}", Math.Ceiling(56.0 / 10.0));//6
//Math.Floor 舍一取整
Console.WriteLine("Math.Floor(54.0/10.0):{0}", Math.Floor(54.0 / 10.0));//5
Console.WriteLine("Math.Floor(56.0/10.0):{0}", Math.Floor(56.0 / 10.0));//5
Unity:
Mathf.Ceil(2.1f); //3