Codecore Logo
Quick Search
»
Advanced Search »

Math Object

RSS
Provides constants and static methods for logarithmic, and other common mathematical functions. This object can not be instantiated in a script. Standard arithmetic operations such as addition, division, etc, are built into the scripting language and can be done without the use the Math class.


Static Properties

E

Gets the constant that represents the natural logarithmic base, specified by the constant, e = 2.7182818284590452354.

Type: Number

Example:


result = Math.E * 10;

PI

Gets the constant that represents the ratio of the circumference of a circle to its diameter, specified by the constant, π = 3.14159265358979323846.

Type: Number

Example:


result = Math.PI * 10;

Static Methods

Abs( Number )

Returns the absolute value of a specified number.

Syntax:

Number Abs(Number value)

Parameters:

value: The Number to be rounded.

Return Value

The absolute value of a specified number

Example:


n1 = Math.Abs(22); // results in 22
n2 = Math.Abs(-22); // results in 22

Round( Number, Number )

Rounds a value to the nearest integer or specified number of decimal places.

Syntax:

Number Round( Number value, Number decimals)

Parameters:

value: A Number to be rounded.

decimals: The number of significant decimal places (precision) in the return value.

Return Value

The Number nearest to vlaue that contains a number of fractional digits equal to decimals.

Example:


n = Math.Round(3.14, 1); // results in 3.1

Pow( Number, Number )

Returns a number raised to the specified power.

Syntax:

Number Pow( Number x, Number power)

Parameters:

x: A Number to be raised to a power.

power: A Number specifying the power.

Return Value

The Number x raised to the specified power.

Example:


n = Math.Power(2, 3); // results in 8

Truncate( Number )

Calculates the integral part of a specified number, that is, the number that remains after any fractional digits have been discarded.

Syntax:

Number Truncate( Number value)

Parameters:

value: A Number to trunctate.

Return Value

The integral part of value; that is, the number that remains after any fractional digits have been discarded. Truncate rounds value to the nearest integer towards zero.

Example:


n = Math.Truncate(12.76); // results in 12
n = Math.Truncate(-12.76); // results in -12

Sign( Number )

Returns a value indicating the sign on a number.

Syntax:

Number Sign( Number value)

Parameters:

value: A Number.

Return Value

A number indicating the sign of value.
-1 = value is less than zero.
0 = value is equal to zero.
1 = value is greater than zero.

Example:


n = Math.Sign(-55); // results in -1

Floor( Number )

Returns the largest number less than or equal to the specified number.

Syntax:

Number Floor( Number value)

Parameters:

value: A Number.

Return Value

The largest number less than or equal to value.

Example:


n = Math.Floor(7.03); // results in 7
n = Math.Floor(7.64); // results in 7
n = Math.Floor(-7.1); // results in -8

Ceiling( Number )

Returns the smallest number greater than or equal to the specified number.

Syntax:

Number Ceiling( Number value)

Parameters:

value: A Number.

Return Value

The smallest number greater than or equal to value.

Example:


n = Math.Ceiling(7.03); // results in 8
n = Math.Ceiling(7.64); // results in 8
n = Math.Ceiling(-7.1); // results in -7

Exp( Number )

Returns e raised to the specified power

Use the Pow method to calculate powers of other bases.

Exp is the inverse of Log.

Syntax:

Number Exp( Number value)

Parameters:

power: A Number specifying the power

Return Value

The number e raised to the specified power.

Example:


n = Math.Floor(7.03); // results in 8

Min( Number, Number )

Returns the smaller of two numbers.

Syntax:

Number Min( Number value1, Number value2)

Parameters:

value1: The first of two numbers to compare.

value2: The second of two numbers to compare.

Return Value

Parameter value1 or value2, whichever is smaller.

Example:


n = Math.Min(2, 3); // results in 2

Max( Number, Number )

Returns the larger of two numbers.

Syntax:

Number Max( Number value1, Number value2)

Parameters:

value1: The first of two numbers to compare.

value2: The second of two numbers to compare.

Return Value

Parameter value1 or value2, whichever is larger.

Example:


n = Math.Max(2, 3); // results in 3

Log( Number )

Returns the natural (base e) logarithm of a specified number.

Syntax:

Number Log( Number value)

Parameters:

value: A Number whose logarithm is to be found, specified as a base 10 number.

Return Value

The natural logarithm of value; that is, ln value, or log e value.

Example:


n = Math.Log(12);

Log( Number, Number )

Returns the logarithm of a specified number in a specified base.

Syntax:

Number Log( Number value, Number newBase)

Parameters:

value: A Number whose logarithm is to be found, specified as a base 10 number.

newBase: The base of the logarithm.

Return Value

The logarithm of a specified number in a specified base.

Example:


n = Math.Log(2, 3);

Log10( Number )

Returns the base 10 logarithm of a specified number.

Syntax:

Number Log10( Number value)

Parameters:

value: A Number whose logarithm is to be found, specified as a base 10 number.

Return Value

The base 10 logarithm of value; that is, log 10 value.

Example:


n = Math.Log10(12);

GetRandomInteger( Number, Number )

Gets a random integer within a specified range.

Syntax:

Number GetRandomInteger( Number min, Number max)

Parameters:

min: The inclusive lower bound of the random number returned.
max: The exclusive upper bound of the random number returned. max must be greater than or equal to min.

Return Value

A Number greater than or equal to minand less than max; that is, the range of return values includes min but not max. If min equals max, min is returned.

Example:


n = Math.GetRandomInteger(1, 20);

GetRandomNumber

Gets a random real Number greater than or equal to 0.0, and less than 1.0.

Syntax:

Number GetRandomNumber( )

Parameters:

none

Return Value

A Number greater than or equal to 0.0, and less than 1.0.

Example:


n = Math.GetRandomNumber( );
Privacy Policy | Conditions Of Use

Copyright ©2014 Codecore Technologies, All rights reserved.