The Math object is used to execute mathematical tasks. Syntax for using Math attributes and Methods: varpi_valueMath.PI; varsqrt_valueMath.sqrt (15); Note: Math objects are not classes of objects like Date and String, so there is no constructor... SyntaxHighlight
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