四舍五入 在计算中 经常使用到,但是如果使用 Math.Round,只是五舍六入
在Math.Round内传入MidpointRounding.AwayFromZero枚举,就可以实现四舍五入的效果了,
Debug.Log($"四舍五入{
66.6}。。。{
(int)Math.Round(66.6, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.5}。。。{
(int)Math.Round(66.5, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.4}。。。{
(int)Math.Round(66.4, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.6}。。。{
(int)Math.Round(66.6)}");
Debug.Log($"四舍五入{
66.5}。。。{
(int)Math.Round(66.5)}");
Debug.Log($"四舍五入{
66.4}。。。{
(int)Math.Round(66.4)}");