我在我的游戏中遇到了一个问题,我必须实现一个将数字除以 3 并使其成为整数的功能。即不是 3.5 或 2.6 等......
它应该是一个整数,例如 3 或 5。
有人知道我该怎么做吗?
最佳答案
Math.Round(num / 3);
或
Math.Ceiling(num / 3);
或
Math.Truncate(num / 3);
关于c# - 除以 3 并向上舍入(如果需要)C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11814175/