Home > Web Front-end > JS Tutorial > body text

Collection of mathematical functions in Javascript_Basic knowledge

WBOY
Release: 2016-05-16 19:13:38
Original
1064 people have browsed it

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template