Set of mathematical functions in Javascript

Source: Internet
Author: User
Tags mathematical functions natural logarithm

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)


Reference
Constants and multiplication Functions

Math. E base (constant) of the natural logarithm 2.718
Math. LN10 10's natural logarithm of 2.302
Math. LN2 2's natural logarithm 0.693
Math. PI circumference rate 3.1415
Math. SQRT1_2 1/2 square root 0.707
Square root of Math. SQRT2 2 1.414
The square root of Math. sqrt (x) X is related to the value of X.
Math. pow (x, n) returns the n power of x. The numerical parameters are x and n.
Math. log (n) returns the natural logarithm of n as n.
Math. exp (n) returns the n power of e. The value parameter is n.

Trigonometric function

Cosine Function of Math. cos (x) X
Sine function of Math. sin (x) X
Math. tan (x) X tangent function
Inverse cosine function of Math. acos (y) X
Math. asin (y) X inverse sine function
Arctangent function of Math. atan (y) 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 () generates a random number from 0 to 1
Math. round (x) returns the value closest to integer x.
Math. floor (x) is a value that is closest to integer x and smaller than x.
Math. ceil (x) is a value closest to integer x and greater than x.
Math. min (a, B, c) returns the smallest value in the parameter list.
Math. max (a, B, c) returns the maximum value in the parameter list.


Http://www.cnlei.org/blog/article.asp? Id = 408

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.