JavaScript Object -- Math

Source: Internet
Author: User
Tags natural logarithm

Math object

Math objects are used to execute mathematical tasks.

Use the attributes and method Syntax of Math:

Var pi_value = Math. PI;

Var sqrt_value = Math. sqrt (15 );

Note: Math objects are not classes of objects as Date and String, So Math () is not a constructor, such as Math. A function like sin () is just a function, not a method of an object. You can call all attributes and methods of a Math object without creating it.

Math Object Attributes

FF: Firefox, IE: Internet Explorer

Attribute
Description
FF
IE
 
E
Returns the base number of the natural logarithm (approximately 2.718) of the arithmetic constant e ).
1
3
 
LN2
Returns the natural logarithm of 2 (approximately 0.693 ).
1
3
 
LN10
Returns the natural logarithm of 10 (approximately 2.302 ).
1
3
 
LOG2E
Returns the base-2 logarithm of e (approximately 1.414 ).
1
3
 
LOG10E
Returns the base-10 logarithm of e (approximately 0.434 ).
1
3
 
PI
Returns the circumference rate (approximately 3.14159 ).
1
3
 
SQRT1_2
Returns the reciprocal of the square root of 2 (approximately 0.707 ).
1
3
 
SQRT2
Returns the square root of 2 (approximately 1.414 ).
1
3
 

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 arc cosine of a number.
1
3
 
Asin (x)
Returns the arc sine of the number.
1
3
 
Atan (x)
Returns the arc tangent value of x with a value between-PI/2 and PI/2 radian.
1
3
 
Atan2 (y, x)
Returns the angle from the x-axis to the point (x, y) (between-PI/2 and PI/2 radian ).
1
3
 
Ceil (x)
The logarithm is rounded up.
1
3
 
Cos (x)
Returns the cosine of the number.
1
3
 
Exp (x)
Returns the index of e.
1
3
 
Floor (x)
The logarithm is deprecated.
1
3
 
Log (x)
Returns the natural logarithm of the number (Base 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 Power y of x.
1
3
 
Random ()
Returns 0 ~ A random number between 1.
1
3
 
Round (x)
Round the number to the nearest integer.
1
3
 
Sin (x)
Returns the sine of the 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 of the 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.