User Tools

Site Tools


Math

The ECMAScript Math object.

More...

Inherits :

Properties

Methods

ECMAScript
Numberabs ( Number num )
Numberacos ( Number num )
Numberasin ( Number num )
Numberatan ( Number num )
Numberatan2 ( Number yCoord, Number xCoord )
Numberceil ( Number num )
Numbercos ( Number num )
Numberexp ( Number num )
Numberfloor ( Number num )
Numberlog ( Number num )
Numbermax ( Number num1, Number num2 )
Numbermin ( Number num1, Number num2 )
Numberpow ( Number num, Number power )
Numberrandom ()
Numberround ( Number num )
Numbersin ( Number num )
Numbersqrt ( Number num )
Numbertan ( Number num )

Detailed Description

This object implements ECMAScript math functions. One instance of the object is automatically created in the global namespace when the script engine is initialized. That instance is accessible via Global::Math. Additional instances of the object cannot be created. See the ECMA script specification for more information.

Todo

Examples:

Properties


Number : E

Euler's constant. The base for natural logarithms. (Read Only)


Number : LN10

Natural logarithm of 10. (Read Only)


Number : LN2

Natural logarithm of 2. (Read Only)


Number : LOG10E

Base 10 logarithm of E. (Read Only)


Number : LOG2E

Base 2 logarithm of E. (Read Only)


Number : PI

Pi (3.141592653589793). (Read Only)


Number : SQRT1_2

Square root of 1/2. (Read Only)


Number : SQRT2

Square root of 2. (Read Only)

Methods


Number : abs( Number num )

Parameter(s):

  • num - The number to take the absolute value of.

Return Value:

  • The absolute value of num.

Number : acos( Number num )

If num is out of range, returns NaN.

Parameter(s):

  • num - The number to calculate the arc cosine of.

Return Value:

  • The arccosine of num in radians between 0 and PI.

Number : asin( Number num )

If num is out of range, returns NaN.

Parameter(s):

  • num - The number to calculate the arc sine of.

Return Value:

  • The arcsine of num in radians between -PI/2 and PI/2.

Number : atan( Number num )

If num is out of range, returns NaN.

Parameter(s):

  • num - The number to calculate the arc tangent of.

Return Value:

  • The arctangent of num in radians between -PI/2 and PI/2.

Number : atan2( Number yCoord, Number xCoord )

Parameter(s):

  • yCoord - The y coordinate of the position to get the arc tangent for.
  • xCoord - The x coordinate of the position to get the arc tangent for.

Return Value:

  • The counter-clockwise angle in radians between the positive x-axis and the point at (xCoord, yCoord). The value returned is always between -PI and PI.

Number : ceil( Number num )

Parameter(s):

  • num - The number to get the ceiling for.

Return Value:

  • If num is an integer, returns num. If num is a float, returns the smallest integer greater than num.

Number : cos( Number num )

Parameter(s):

  • num - The angle, in radians, to calculate the cosine of.

Return Value:

  • The cosine of num. The value will be in the range [-1,1].

Number : exp( Number num )

Parameter(s):

  • num - The exponent to calculate.

Return Value:

  • E raised to the power of num.

Number : floor( Number num )

Parameter(s):

  • num - The number to get the floor for.

Return Value:

  • If num is an integer, returns num. If num is a float, returns the greatest integer less than num.

Number : log( Number num )

Parameter(s):

  • num - The number to calculate the logarithm of.

Return Value:

  • If num is > 0, returns the natural logarithm of num. If num is 0, returns Infinity. If num is < 0, returns NaN.

Number : max( Number num1, Number num2 )

Parameter(s):

  • num1 - The first number to test.
  • num2 - The second number to test.

Return Value:

  • The larger of num1 and num2.

Number : min( Number num1, Number num2 )

Parameter(s):

  • num1 - The first number to test.
  • num2 - The second number to test.

Return Value:

  • The smaller of num1 and num2.

Number : pow( Number num, Number power )

Parameter(s):

  • num - The number to calculate the exponent of.
  • power - The exponent of the number to calculate.

Return Value:

  • The value of num raised to power.

Number : random()

Return Value:

  • A pseudo-random float between 0 and 1. Pseudo random numbers are not truly random, but may be adequate for some applications, for example, games and simple simulations.

Number : round( Number num )

Parameter(s):

  • num - The number to round off.

Return Value:

  • num rounded to the nearest integer. If the fractional part of num is >= 0.5, num is rounded up; otherwise it is rounded down.

Number : sin( Number num )

Parameter(s):

  • num - The angle, in radians, to calculate the sine of.

Return Value:

  • The sine of num. The value will be in the range [-1,1].

Number : sqrt( Number num )

Parameter(s):

  • num - The number to calculate the square root of.

Return Value:

  • If num is >= 0, returns the square root. If num is < 0, returns NaN.

Number : tan( Number num )

Parameter(s):

  • num - The angle, in radians, to calculate the tangent of.

Return Value:

  • The tangent of num.