A set of mathematical functions in JavaScript basics

Source: Internet
Author: User
Tags constant numeric mathematical functions natural logarithm square root
In JavaScript, mathematical methods can be grouped into the following categories:
Constans (constant), power functions (exponentiation function), trigonometic functions (trigonometric function), rounding functions (rounding functions), random numbers (random number)


Reference
Constants and exponentiation functions

MATH.E of the natural logarithm (for constant) 2.718
Natural logarithm of math.ln10 10 2.302
Natural logarithm of MATH.LN2 2 0.693
Math.PI Pi 3.1415
Math.sqrt1_2 1/2 Square root 0.707
Math.sqrt2 2 square root 1.414
MATH.SQRT (x) x has a value for the square root more X
Math.pow (x, N) returns the N-second square of x with a numeric parameter of x and N
Math.log (n) returns the natural logarithm parameter n of n
MATH.EXP (n) returns the N-second side of E with a numeric parameter of n

Trigonometric function

cosine function of Math.Cos (x) x
sine function of Math.sin (x) x
Tangent function of Math.tan (x) x
Inverse cosine function of Math.acos (y) x
Math.asin (y) x's inverse chord function
Inverse tangent function of Math.atan (y) x

Note here: Both the parameter X and the units of the returned values of the inverse function are radians (for example, pi radians = 180 degrees)

Rounding functions and random numbers

Math.random () generates random numbers from 0 to 1
Math.Round (x) takes the nearest integer x value
Math.floor (x) takes the nearest integer x and the number smaller than X
Math.ceil (x) takes the nearest integer x and is larger than X
Math.min (A, B, c) returns the smallest number in the argument list
Math.max (A, B, c) returns the largest number in the argument list


Original: 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.