1. 程式人生 > >Math

Math

pow app ceil 獲取 and math 最小 求最大值 con

Math方法

  • Math.abs(-12) // 12 取絕對值
  • Math.ceil(12.3) //13 向上取整
  • Math.floor(12.3) //12 向下取整
  • Math.round() 四舍五入
  • Math.max(12,3,43,23,45,32,54) 求最大值
  • Math.min(12,32,32,23,1,23,4) 求最小值
  • Math.random() 獲取0到1之間的隨機小數
  • Math.sqrt 開平方 Math.sqrt(100) //10
  • Math.pow 求冪 Math.pow(10,3) //1000
  • Math.PI 圓周率 Math.PI //3.1415926..
  • Math.round(Math.random()*(m-n)+n) 獲取n到m之間的隨機整數

Math