In JavaScript, mathematical methods can be divided into the following types:
Constans (constant), power functions (multiplication function), trigonometic functions (trigonometric function), rounding functions (rounding function), random numbers (random number)
Constants and multiplication Functions
| Math. e |
Base of natural logarithm (constant) |
2.718 |
| Math. ln10 |
Natural logarithm of 10 |
2.302 |
| Math. ln2 |
Natural logarithm of 2 |
0.693 |
| Math. Pi |
Circumference Rate |
3.1415 |
| Math. sqrt1_2 |
Square root of 1/2 |
0.707 |
| Math. sqrt2 |
Square root of 2 |
1.414 |
| Math. SQRT (X) |
Square root of X |
It depends on the value of X. |
| Math. Pow (x, n) |
Returns the nth power of X. |
The parameters are X and N. |
| Math. Log (N) |
Returns the natural logarithm of N. |
The parameter is N. |
| Math. exp (N) |
Returns the nth power of E. |
The parameter is N. |
Trigonometric function
| Math. Cos (X) |
Returns the cosine of X. |
| Math. Sin (X) |
Sine function of X |
| Math. Tan (X) |
Returns the tangent of X. |
| Math. ACOs (y) |
Returns the arc cosine of X. |
| Math. asin (y) |
Returns the arcsin of X. |
| Math. atan (y) |
Returns the arc tangent function of X. |
Note: The unit of the return values of parameter X and inverse functions is radian (for example, PI radian = 180 degrees)
Rounding functions and random numbers
| math. Random () |
Generate a random number from 0 to 1 |
| math. Round (x) |
returns the value closest to integer x |
& Lt; TD width = "50%" & gt; math. Floor (x) & lt;/TD & gt;
| take the value closest to integer x and smaller than x |
& Lt; TD width = "50%" & gt; math. Ceil (x) & lt;/TD & gt;
| take the value closest to integer x and greater than x |
| math. Min (a, B, c) |
return the smallest value in the parameter list |
| math. Max (a, B, c) |
return the maximum value in the parameter list |