Predeclared in MATH

Constants

(constant) math_E :number

The Number value for e, Euler's number, which is approximately 2.718281828459045.
Type:
  • number

(constant) math_LN2 :number

The Number value for the natural logarithm of 2, which is approximately 0.6931471805599453.
Type:
  • number

(constant) math_LN10 :number

The Number value for the natural logarithm of 10, which is approximately 2.302585092994046.
Type:
  • number

(constant) math_LOG2E :number

The Number value for the base-2 logarithm of eℝ, the base of the natural logarithms; this value is approximately 1.4426950408889634.

NOTE: The value of math_LOG2E is approximately the reciprocal of the value of math_LN2.

Type:
  • number

(constant) math_LOG10E :number

The Number value for the base-10 logarithm of e, the base of the natural logarithms; this value is approximately 0.4342944819032518.

NOTE: The value of math_LOG10E is approximately the reciprocal of the value of math_LN10.

Type:
  • number

(constant) math_PI :number

The Number value for π, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932.
Type:
  • number

(constant) math_SQRT1_2 :number

The Number value for the square root of 0.5, which is approximately 0.7071067811865476.

NOTE: The value of math_SQRT1_2 is approximately the reciprocal of the value of math_SQRT2.

Type:
  • number

(constant) math_SQRT2 :number

The Number value for the square root of 2, which is approximately 1.4142135623730951.
Type:
  • number

Functions

math_abs(x) → {number}

computes the absolute value of x; the result has the same magnitude as x but has positive sign.
Parameters:
Name Type Description
x number given number
Returns:
absolute value of x
Type
number

math_acos(x) → {number}

computes the arc cosine of x. The result is expressed in radians and ranges from +0 to +π.
Parameters:
Name Type Description
x number given number
Returns:
arc cosine of x
Type
number

math_acosh(x) → {number}

computes the inverse hyperbolic cosine of x.
Parameters:
Name Type Description
x number given number
Returns:
inverse hyperbolic cosine of x.
Type
number

math_asin(x) → {number}

computes the arc sine of x. The result is expressed in radians and ranges from -π / 2 to +π / 2.
Parameters:
Name Type Description
x number given number
Returns:
arc sine of x.
Type
number

math_asinh(x) → {number}

computes the inverse hyperbolic sine of x. The result is expressed in radians and ranges from -π / 2 to +π / 2.
Parameters:
Name Type Description
x number given number
Returns:
inverse hyperbolic sine of x
Type
number

math_atan(x) → {number}

computes the arc tangent of x. The result is expressed in radians and ranges from -π / 2 to +π / 2.
Parameters:
Name Type Description
x number given number
Returns:
arc tangent of x
Type
number

math_atan2(y, x) → {number}

computes the arc tangent of the quotient y / x of the arguments y and x, where the signs of y and x are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument arc tangent function that the argument named y be first and the argument named x be second. The result is expressed in radians and ranges from -π to +π.
Parameters:
Name Type Description
y number given first number
x number given second number
Returns:
arc tangent of y / x.
Type
number

math_atanh(x) → {number}

computes the inverse hyperbolic tangent of x.
Parameters:
Name Type Description
x number given number
Returns:
inverse hyperbolic tangent of x.
Type
number

math_cbrt(x) → {number}

computes the cube root of x.
Parameters:
Name Type Description
x number given number
Returns:
cube root of x.
Type
number

math_ceil(x) → {number}

computes the smallest (closest to -∞) Number value that is not less than x and is an integer. If x is already an integer, the result is x. The value of math_ceil(x) is the same as the value of -math_floor(-x).
Parameters:
Name Type Description
x number given number
Returns:
"ceiling" of the number
Type
number

math_clz32(n) → {number}

When math_clz32 is called with one argument x, the following steps are taken: Let n be ToUint32(x). Let p be the number of leading zero bits in the 32-bit binary representation of n. Return p.

NOTE:
If n is 0, p will be 32. If the most significant bit of the 32-bit binary encoding of n is 1, p will be 0.

Parameters:
Name Type Description
n number given number
Returns:
p - leading zero bits
Type
number

math_cos(x) → {number}

Computes the cosine of x. The argument is expressed in radians.
Parameters:
Name Type Description
x number given number
Returns:
- cosine of x
Type
number

math_cosh(x) → {number}

computes the hyperbolic cosine of x.

NOTE: The value of cosh(x) is the same as (exp(x) + exp(-x)) / 2.

Parameters:
Name Type Description
x number given number
Returns:
hyperbolic cosine of x
Type
number

math_exp(x) → {number}

computes the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
Parameters:
Name Type Description
x number given number
Returns:
e to the power of x
Type
number

math_expm1(x) → {number}

computes subtracting 1 from the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms). The result is computed in a way that is accurate even when the value of x is close to 0.
Parameters:
Name Type Description
x number given number
Returns:
-1 plus e to the power of x
Type
number

math_floor(x) → {number}

computes the greatest (closest to +∞) Number value that is not greater than x and is an integer.
If x is already an integer, the result is x.

NOTE: The value of math_floor(x) is the same as the value of -math_ceil(-x).

Parameters:
Name Type Description
x number given number
Returns:
floor of x
Type
number

math_fround(x) → {number}

When math_fround is called with argument x, the following steps are taken:
  1. If x is NaN, return NaN.
  2. If x is one of +0, -0, +∞, -∞, return x.
  3. Let x32 be the result of converting x to a value in IEEE 754-2008 binary32 format using roundTiesToEven mode.
  4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.
  5. Return the ECMAScript Number value corresponding to x64.
Parameters:
Name Type Description
x number given number
Returns:
fround of x
Type
number

math_hypot() → {number}

computes the square root of the sum of squares of its arguments.
If no arguments are passed, the result is +0.
Parameters:
Name Type Description
value1,value2,... number given numbers
Returns:
square root of sum of squares of arguments
Type
number

math_imul(x, x) → {number}

When math_imul is called with arguments x and y, the following steps are taken:
  1. Let a be ToUint32(x).
  2. Let b be ToUint32(y).
  3. Let product be (a × b) modulo 232.
  4. If product ≥ 231, return product - 232; otherwise return product.
Parameters:
Name Type Description
x number given first number
x number given second number
Returns:
- x imul y
Type
number

math_log(x) → {number}

Computes the natural logarithm of x.
Parameters:
Name Type Description
x number given number
Returns:
- natural logarithm of x
Type
number

math_log1p(x) → {number}

computes the natural logarithm of 1 + x. The result is computed in a way that is accurate even when the value of x is close to zero.
Parameters:
Name Type Description
x number given number
Returns:
math_log(1 + x)
Type
number

math_log2(x) → {number}

computes the base 2 logarithm of x.
Parameters:
Name Type Description
x number given number
Returns:
base 2 logarithm of x
Type
number

math_log10(x) → {number}

computes the base 10 logarithm of x.
Parameters:
Name Type Description
x number given number
Returns:
base 10 logarithm of x
Type
number

math_max() → {number}

Given zero or more numbers, returns the largest of them.
If no arguments are given, the result is -∞.
If any value is NaN, the result is NaN. The comparison of values to determine the largest value is done using the Abstract Relational Comparison algorithm except that +0 is considered to be larger than -0.
Parameters:
Name Type Description
value1,value2,... number given numbers
Returns:
largest of them
Type
number

math_min() → {number}

Given zero or more arguments, returns the smallest of them.
If no arguments are given, the result is +∞.
If any value is NaN, the result is NaN. The comparison of values to determine the smallest value is done using the Abstract Relational Comparison algorithm except that +0 is considered to be larger than -0.
Parameters:
Name Type Description
value1,value2,... number given numbers
Returns:
smallest of them
Type
number

math_pow(base, exponent) → {number}

Computes the result of raising base to the power of exponent.
Parameters:
Name Type Description
base number the given base
exponent number the given exponent
Returns:
base to the power of exponent
Type
number

math_random() → {number}

Returns a number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy. This function takes no arguments. Each math_random function created for distinct realms must produce a distinct sequence of values from successive calls.
Returns:
random number greater than or equal to 0 but less than 1
Type
number

math_round(x) → {number}

Returns the number value that is closest to x and is an integer.
If two integers are equally close to x, then the result is the Number value that is closer to +∞. If x is already an integer, the result is x. NOTE 1: math_round(3.5) returns 4, but math_round(-3.5) returns -3.
Parameters:
Name Type Description
x number the given number
Returns:
closest integer to x
Type
number

math_sign(x) → {number}

Computes the sign of x, indicating whether x is positive, negative, or zero.
Parameters:
Name Type Description
x number the given number
Returns:
the sign (-1, 0 or +1)
Type
number

math_sin(x) → {number}

Computes the sine of x. The argument is expressed in radians.
Parameters:
Name Type Description
x number the given number
Returns:
the sine of x
Type
number

math_sinh(x) → {number}

Computes the hyperbolic sine of x.

NOTE: The value of sinh(x) is the same as (exp(x) - exp(-x)) / 2.

Parameters:
Name Type Description
x number the given number
Returns:
the hyperbolic sine of x
Type
number

math_sqrt(x) → {number}

Computes the square root of x.
Parameters:
Name Type Description
x number the given number
Returns:
the square root of x
Type
number

math_tan(x) → {number}

Computes the tangent of x. The argument is expressed in radians.
Parameters:
Name Type Description
x number the given number
Returns:
the tangent of x
Type
number

math_tanh(x) → {number}

Computes the hyperbolic tangent of x.

NOTE: The value of math_tanh(x) is the same as (exp(x) - exp(-x))/(exp(x) + exp(-x)).

Parameters:
Name Type Description
x number the given number
Returns:
the hyperbolic tangent of x
Type
number

math_trunc(x) → {number}

Computes the integral part of the number x, removing any fractional digits.
Parameters:
Name Type Description
x number the given number
Returns:
the integral part of x
Type
number