C#除法的取整

版权声明:望生帝 https://blog.csdn.net/qq_36664495/article/details/84439096

Math.Round:四舍六入五取整

Math.Ceiling:向上取整,只要有小数都加1

Math.Floor:向下取整,总是舍去小数

 

使用的时候,说函数具有二义性。所以使用如下:

(int)Math.Ceiling((double)xor/12);

Xor/12取整还是double型是具有二义性的。

猜你喜欢

转载自blog.csdn.net/qq_36664495/article/details/84439096