Skip to content

Math常用方法

INFO

  • Math.ceil(): 对数进行上舍入(天花板函数)

  • Math.floor(): 对数进行下舍入(地板函数)。

  • Math.max(x,y): 返回 x,y 中的最大值。

  • Math.min(x,y): 返回 x,y 中的最小值。

  • Math.pow(x,y): 返回 x 的 y 次方。

  • Math.random() : 返回 0-1 之间的随机数。

  • Math.round(x): 四舍五入。

  • Math.abs(x): 返回数的绝对值。

  • Math.acos(x): 返回数的反余弦值。

  • Math.asin(x): 返回数的反正弦值。

  • Math.atan(x): 返回数的反正切值。

  • Math.atan2(y,x): 返回由 x 轴到点(x,y)的角度(以弧度为单位)。

  • Math.cos(x): 返回数的余弦值。

  • Math.exp(e): 返回 e 的指数。

  • Math.log(x): 返回数的自然对数(以 e 为底数)。

  • Math.sin(x): 返回数的正弦值。

  • Math.sqrt(x): 返回数的平方根。

  • Math.tan(x): 返回角的正切值。

  • Math.toSource(): 返回该对象的源代码。

  • Math.valueOf(): 返回 Math 对象的原始值。