Math的用法

  Math.round(3.6)     //四舍五入
  Math.random()       //返回0-1之间的随机数 [0,1)
  Math.max(num1, num2)   //返回较大的数
  Math.min(num1, num2)   //返回较小的数
  Math.abs(num)       //绝对值
  Math.ceil(19.3)     //向上取整  -2.9  -2  2.1  3
  Math.floor(11.8)    //向下取整  -2.9  -3  2.1  2
  Math.pow(x,y)       //x的y次方
  Math.sqrt(num)      //开平方
  Math.PI              //π 常量

猜你喜欢

转载自blog.csdn.net/qq_45785424/article/details/106473852