Basic knowledge of mathematical functions in Javascript

Source: Internet
Author: User
Tags mathematical functions natural logarithm
Mathematical functions in Javascript are classified into the following mathematical methods:
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.
Math. floor (x) Returns the value closest to integer x and smaller than x.
Math. ceil (x) Returns the 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.
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.