parseInt(5/2) 丢弃小数部分,保留整数部分 Math.ceil(5/2) 向上取整,有小数就整数部分加1 Math.round(5/2) 四舍五入. Math.floor(5/2) 向下取整 Math.random() 返回 0 ~ 1 之间的随机数. Math.abs(x) 返回数的绝对值. Math.acos(x) 返回数的反余弦值. Math.asin(x) 返回数的反正弦值. Math.atan(x) 以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值. Math.atan2(y,x) 返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间). Math.ceil(x) 对一个数进行上舍入. Math.cos(x) 返回数的余弦. Math.exp(x) 返回 e 的指数. Math.floor(x) 对一个数进行下舍入. Math.log(x) 返回数的自然对数(底为e). Math.max(x,y) 返回 x 和 y 中的最高值. Math.min(x,y) 返回 x 和 y 中的最低值. Math.pow(x,y) 返回 x 的 y 次幂. Math.round(x) 把一个数四舍五入为最接近的整数. Math.sin(x) 返回数的正弦. Math.sqrt(x) 返回数的平方根. Math.tan(x) 返回一个角的正切. |