The method of JS Math object __js

Source: Internet
Author: User
Tags natural logarithm square root
the method of JS Math objectJS Math object method to take the whole up, down rounding, rounding and so on, digital operations are often used, the need for friends can refer to the

1. Discard the fractional part and keep the whole number of parts

parseint (5/2)

2. Take up the whole, there are decimal numbers on the whole part plus 1

Math.ceil (5/2)

3, rounded.

Math.Round (5/2)

4, take the whole down.

Math.floor (5/2)

Math Object Method

Ff:firefox, Ie:internet Explorer

Method Description FF IE
ABS (x) Returns the absolute value of a number. 1 3
ACOs (x) Returns the inverse cosine of a number. 1 3
ASIN (x) Returns the inverse chord value of a number. 1 3
Atan (x) Returns the inverse tangent of x to the value between-PI/2 and PI/2 radians. 1 3
ATAN2 (y,x) Returns the angle (between-PI/2 and PI/2 radians) from the X axis to point (X,y). 1 3
Ceil (x) The logarithm is rounded up. 1 3
COS (x) Returns the cosine of a number. 1 3
EXP (x) Returns the index of E. 1 3
Floor (x) The logarithm is rounded down. 1 3
Log (x) Returns the natural logarithm of the number (the bottom is e). 1 3
Max (X,y) Returns the highest value in X and Y. 1 3
Min (x,y) Returns the lowest value in X and Y. 1 3
Pow (x,y) Returns the Y-power of X. 1 3
Random () Returns the random number between 0 ~ 1. 1 3
Round (x) Round the number to the nearest integer. 1 3
Sin (x) Returns the sine of a number. 1 3
sqrt (x) Returns the square root of a number. 1 3
Tan (x) Returns the tangent of the angle. 1 3
Tosource () Returns the source code for this object. 1 -
ValueOf () Returns the original value of the Math object. 1 4
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.