Home  >  Article  >  Web Front-end  >  Collection of mathematical functions in Javascript_Basic knowledge

Collection of mathematical functions in Javascript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:13:381061browse

In Javascript, mathematical methods can be divided into the following categories:
consstans (constants), power functions (power functions), trigonometic functions (trigonometric functions), rounding functions (rounding functions), random numbers (random numbers)


Quote
Constant and power functions

Math.E The base of the natural logarithm (is a constant) 2.718
Math.LN10 The natural logarithm of 10 2.302
Math.LN2 Natural logarithm of 2 0.693
Math.PI Pi 3.1415
Math.SQRT1_2 Square root of 1/2 0.707
Math.SQRT2 Square root of 2 1.414
Math.sqrt(x) X The square root of is related to the value of X.
Math.pow(x, n) Returns the n value of 🎜>Math.exp(n) Returns the value of e raised to the nth power. The parameter is n.

Trigonometric function

Math.cos(x) The cosine function of X.
Math.sin( x) sine function of X
Math.tan(x) tangent function of X
Math.acos(y) inverse cosine function of Math.atan(y) Arctangent function of Functions and Random Numbers

Math.random() Generate random numbers from 0 to 1
Math.round(x) Get the closest value to the integer x
Math.floor(x) Get the closest A value close to an integer x and smaller than x
Math.ceil(x) Gets the value closest to an integer x and larger than x 🎜>Math.max(a, b, c) Returns the largest value in the parameter list


Original text: http://www.cnlei.org/blog/article.asp?id=408

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn