Math.Round:四舍六入五取整Math.Ceiling:向上取整,只要有小数都加1
Math.Floor:向下取整,总是舍去小数
示例:1.Math.Round:四舍六入五取偶Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) //0Math.Round(0.4) //0Math.Round(0.5) //0Math.Round(0.6) //1Math.Round(0.7) //1Math.Round(0.8) //1Math.Round(0.9) //1说明:对于1.5,因要返回偶数,所以结果为2。2.Math.Ceiling:只要有小数都加1Math.Ceiling(0.0) //0Math.Ceiling(0.1) //1Math.Ceiling(0.2) //1Math.Ceiling(0.3) //1Math.Ceiling(0.4) //1Math.Ceiling(0.5) //1Math.Ceiling(0.6) //1Math.Ceiling(0.7) //1Math.Ceiling(0.8) //1Math.Ceiling(0.9) //1说明:例如在分页算法中计算分页数很有用。3.Math.Floor:总是舍去小数Math.Floor(0.0) //0Math.Floor(0.1) //0Math.Floor(0.2) //0Math.Floor(0.3) //0Math.Floor(0.4) //0Math.Floor(0.5) //0Math.Floor(0.6) //0Math.Floor(0.7) //0Math.Floor(0.8) //0Math.Floor(0.9) //0
新闻热点
疑难解答