Math

Math

一,Math.abs()  求绝对值

  Math.PI 圆周率

二,求近似值:

  1.Math.round()   四舍五入

    负数: >0.5进1        <=  0.5舍去

  2. Math.ceil()   向上取整

  3.Math.floor()  向下取整

三,求最值

  1.Math.max()  最大值。2,Math.min()  最小值;

  扩展:Math.max.apply(null,数组);

四,求随机数

  Math.random()   0<= n < 1

Math.floor(Math.random() * (max - min + 1) + min);

 

  

五,求M的n次方

  Math.pow(2,10);

六,求开方

  Math.sqrt(x )

posted @ 2019-02-14 00:00  胡鑫&  阅读(315)  评论(0编辑  收藏  举报