Math Class
Math class provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
Item Index
Methods
atan
number
[number]
Returns arctangent if its arguments.
Parameters:
Returns:
atan2
x
y
Returns the principal value of the arc tangent of y/x,
Parameters:
Returns:
ceil
number
Rounds a number up - returns the smallest integer greater than or equal to the argument.
Example:
var a = Math.ceil(1.5); // return 2
exp
number
Returns the exponential value of the argument, if successful. On overflow, the function returns INF (infinite) and on underflow, exp returns 0.0. To test number on infinity use isFinite method.
log
number
Calculate natural logarithms of the argument. If argument is negative, these functions throws an exception.
Returns:
log10
number
The log functions return common (base-10) logarithm of the argument if successful. If argument is negative, these functions throws an exception.
Returns:
log2
number
The log functions return base-2 logarithms of the argument if successful. If argument is negative, these functions throws an exception.
Returns:
pow
number
number
Calculates number raised to the power of exponent: result = number^exponent;
Returns:
round
number
Mathematically rounds a number.
Parameters:
-
number
FloatFloat number to round
Returns:
Example:
Math.round(1.5); // returns 2
Math.round(1.4); // returns 1