Moscrif API Docs for: 2012q3
Show:

Math Class

Library: core

Math class provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.

Methods

abs

(
  • number
)
Float | Integer

Calculates abs (positive) value of integer or float argument.

Parameters:

Returns:

Float | Integer: Absolute (positive) Value number.

acos

(
  • angle
)
Float | Integer

Calculates arccosine of its argument.

Parameters:

Returns:

Float | Integer: Arccosine of argument.

asin

(
  • angle
)
Float | Integer

Calculates arcsine of its argument.

Parameters:

Returns:

Float | Integer: Arcsine of argument.

atan

(
  • number
  • [number]
)
Float

Returns arctangent if its arguments.

Parameters:

  • number Float | Integer

    Value to calculate arccosine.

  • [number] Float | Integer optional multiple

    Value to calculate arccosine.

Returns:

Float: Returns arctangent if its arguments.

atan2

(
  • x
  • y
)
Float

Returns the principal value of the arc tangent of y/x,

Parameters:

Returns:

Float: Returns arctangent of y/x.

ceil

(
  • number
)
Float | Integer

Rounds a number up - returns the smallest integer greater than or equal to the argument.

Parameters:

Returns:

Float | Integer: The smallest integer greater than or equal to the argument.

Example:

var a = Math.ceil(1.5); // return 2

cos

(
  • angle
)
Float | Integer

Calculates value of cosine function for angle in parameter.

Parameters:

Returns:

Float | Integer: Absolute (positive) Cosine of angle.

exp

(
  • number
)
Float | Integer

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.

Parameters:

Returns:

Float | Integer: The smallest integer greater than or equal to the argument.

log

(
  • number
)
Float

Calculate natural logarithms of the argument. If argument is negative, these functions throws an exception.

Parameters:

Returns:

Float: Natural logarithms of the number in argument.

log10

(
  • number
)
Float

The log functions return common (base-10) logarithm of the argument if successful. If argument is negative, these functions throws an exception.

Parameters:

Returns:

Float: 2-based logarithms of the number in argument.

log2

(
  • number
)
Float

The log functions return base-2 logarithms of the argument if successful. If argument is negative, these functions throws an exception.

Parameters:

Returns:

Float: 10-based logarithms of the number in argument.

pow

(
  • number
  • number
)
Float

Calculates number raised to the power of exponent: result = number^exponent;

Parameters:

Returns:

Float: Number raised to the power of exponent.

round

(
  • number
)
Integer

Mathematically rounds a number.

Parameters:

  • number Float

    Float number to round

Returns:

Integer: Rounded number

Example:

Math.round(1.5); // returns 2
Math.round(1.4); // returns 1

sign

(
  • angle
)
Float | Integer

Calculates value of sine function for angle in parameter.

Parameters:

Returns:

Float | Integer: Absolute (positive) Sine of angle.

sqrt

(
  • number
)
Float | Integer

Returns the square root of the argument.

Parameters:

  • number Float | Integer

    Number to calculate the square root.

Returns:

Float | Integer: The square root of the argument.

tan

(
  • angle
)
Float | Integer

Calculates value of tanget function for angle in parameter.

Parameters:

Returns:

Float | Integer: Tangent of angle.

Properties

E

Float

e - Euler's constant, the base of natural logarithms.

LN10

Float

Value of natural logarithm of 10.

LN2

Float

Value of natural logarithm of 2.

LOG10E

Float

Value of base 10 logarithm of e constant.

PI

Float

Pi constant - the ratio of the circumference of a circle to its diameter.

SQRT1_2

Float

Value of square root of 0.5.

SQRT2

Float

Value of square root of 2.0.