Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Math 对象属性 #
- E
- PI
- # Math 对象方法 #
- max(x,y) 返回 x 和 y 中的最高值。 参数为两个及以上
- min(x,y) 返回 x 和 y 中的最低值。
- Math.ceil(x) ceil() 方法可对一个数进行向上取整。
- ceil() 方法执行的是向上取整计算,它返回的是大于或等于函数参数,并且与之最接近的整数。
- Math.floor(x) floor() 方法可对一个数进行向下取整。
- Math.round(x) round() 方法可把一个数字舍入为最接近的整数。
- Math.random() random() 方法可返回介于 0 ~ 1 之间的一个随机数。 [0,1)
- Math.abs(x) 返回数的绝对值。
- Math.exp(x) exp() 方法可返回 e 的 x次方。
- Math.log(x) 返回数的自然对数(底为e)。
- Math.pow(x,y) pow() 方法可返回 x 的 y 次方的值。
- Math.sqrt(4) sqrt() 方法可返回一个数的平方根。
- 案例:(产生一个10到40的随机数
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement