Cloud Software Group, Inc. EBX®
Documentation > Developer Guide > EBX® Script > API
Navigation mode Documentation > Developer Guide > EBX® Script > API

# Unit core.math

Script unit that provides mathematical functions and constants.

Methods
function abs(value: decimal): decimal Returns the absolute value of a decimal value.
function acos(value: decimal): decimal Returns the arc cosine of a value.
function asin(value: decimal): decimal Returns the arc sine of a value.
function atan(value: decimal): decimal Returns the arc tangent of a value.
function cbrt(value: decimal): decimal Returns the cube root of a decimal value.
function ceil(value: decimal): decimal Returns the integer ceil value of the input value.
function cos(value: decimal): decimal Returns the trigonometric cosine of an angle.
function e(): decimal Returns e value: 2.
function exp(value: decimal): decimal Returns Euler's number e raised to the power of a decimal value.
function floor(value: decimal): decimal Returns the integer floor value of the input value.
function log(value: decimal): decimal Returns the natural logarithm (base e) of the input value.
function max(a: decimal, b: decimal): decimal Returns the larger of two decimal values.
function min(a: decimal, b: decimal): decimal Returns the smaller of two decimal values.
function pi(): decimal Returns pi value: 3.
function pow(a: decimal, b: decimal): decimal Returns the value of the first argument raised to the power of the second argument.
function random(): decimal Returns a random decimal value with a positive sign, greater than or equal to 0 and less than 1.
function randomInt(maxValue: decimal): decimal Returns a random integer between 0 (inclusive) and the specified `bound` (exclusive).
function round(value: decimal): decimal Returns the integer round value of the input value.
function roundDown(value: decimal): decimal Returns the integer round down value of the input value.
function roundHalfDown(value: decimal): decimal Returns the integer round half down value of the input value.
function roundHalfEven(value: decimal): decimal Returns the integer round half even value of the input value.
function roundUp(value: decimal): decimal Returns the integer round up value of the input value.
function scaleByPowerOfTen(value: decimal, power: decimal): decimal Returns the value scale by power of ten.
function sin(value: decimal): decimal Returns the trigonometric sine of an angle.
function sqrt(value: decimal): decimal Returns the positive square root of a value.
function tan(value: decimal): decimal Returns the trigonometric tangent of an angle.
function toDegrees(value: decimal): decimal Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
function toRadians(value: decimal): decimal Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

## abs

function abs(value: decimal): decimal

Returns the absolute value of a decimal value.

Parameters :

value: the input value.

Return :

the absolute value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## acos

function acos(value: decimal): decimal

Returns the arc cosine of a value.

The returned angle is in the range 0.0 through pi.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value. Absolute value must not be greater than 1.

Return :

the arc cosine of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## asin

function asin(value: decimal): decimal

Returns the arc sine of a value.

The returned angle is in the range -pi/2 through pi/2.

Special cases:

If the input value is zero, then the result is a zero.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value. Absolute value must not be greater than 1.

Return :

the arc sine of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## atan

function atan(value: decimal): decimal

Returns the arc tangent of a value.

The returned angle is in the range -pi/2 through pi/2.

Special cases:

If the input value is zero, then the result is a zero.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value.

Return :

the arc tangent of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## cbrt

function cbrt(value: decimal): decimal

Returns the cube root of a decimal value. Calculations use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value.

Return :

the cube root of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## ceil

function ceil(value: decimal): decimal

Returns the integer ceil value of the input value.

Parameters :

value: the input value.

Return :

the ceil value of the input value or null if input value is null..

Can be used in: Script tasks, Table triggers, Function fields

## cos

function cos(value: decimal): decimal

Returns the trigonometric cosine of an angle.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value in radians.

Return :

the cosine of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## e

function e(): decimal

Returns e value: 2.718281828459045235360287471352662

Return :

e value.

Can be used in: Script tasks, Table triggers, Function fields

## exp

function exp(value: decimal): decimal

Returns Euler's number e raised to the power of a decimal value.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value.

Return :

the value e^value where e is the base of the natural logarithms.

If the input value is null returns null.

Can be used in: Script tasks, Table triggers, Function fields

## floor

function floor(value: decimal): decimal

Returns the integer floor value of the input value.

Parameters :

value: the input value.

Return :

the floor value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## log

function log(value: decimal): decimal

Returns the natural logarithm (base e) of the input value.

Calculations use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value. Must be strictly greater than zero.

Return :

the natural logarithm of the input value a or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## max

function max(a: decimal, b: decimal): decimal

Returns the larger of two decimal values.

Example:

    uses core.math as m;
    procedure doSomething()
    begin
      var result := m.max(10, 5); // 10
      ...
    end

Parameters :

a The first input value

b The second input value

Return :

The larger of the two input values

Can be used in: Script tasks, Table triggers, Function fields

## min

function min(a: decimal, b: decimal): decimal

Returns the smaller of two decimal values.

Example:

    uses core.math as m;
    procedure doSomething()
    begin
      var result := m.min(10, 5); // 5
      ...
    end

Parameters :

a The first input value

b The second input value

Return :

The smaller of the two input values

Can be used in: Script tasks, Table triggers, Function fields

## pi

function pi(): decimal

Returns pi value: 3.141592653589793238462643383279503

Return :

pi value.

Can be used in: Script tasks, Table triggers, Function fields

## pow

function pow(a: decimal, b: decimal): decimal

Returns the value of the first argument raised to the power of the second argument. The parameter n must be in the range -999999999 through 999999999, inclusive. pow(0, 0) returns 1.

Example:

    uses core.math as m;
    procedure doSomething()
    begin
      var result := m.pow(2, 3); // 8
      ...
    end

Parameters :

a The base input value

b The exponent input value

Return :

The result of a raised to the power of b

Can be used in: Script tasks, Table triggers, Function fields

## random

function random(): decimal

Returns a random decimal value with a positive sign, greater than or equal to 0 and less than 1. Attention, this method is not pure.

Example:

    uses core.math as m;
    procedure doSomething()
    begin
      var result := m.random(); // 0.8574303492
      ...
    end

Return :

A decimal value between 0 (inclusive) and 1 (exclusive)

Can be used in: Script tasks, Table triggers, Function fields without search optimization

## randomInt

function randomInt(maxValue: decimal): decimal

Returns a random integer between 0 (inclusive) and the specified `bound` (exclusive). Attention, this method is not pure.

Example:

    uses core.math as m;
    procedure doSomething()
    begin
      var result := m.randomInt(10); // a random integer between 0 and 9
      ...
    end

Parameters :

bound The upper bound (exclusive), must be positive

Return :

A random integer between 0 (inclusive) and `bound` (exclusive)

Can be used in: Script tasks, Table triggers, Function fields without search optimization

## round

function round(value: decimal): decimal

Returns the integer round value of the input value. This method uses the standard round half up rounding mode.

Parameters :

value: the input value.

Return :

the round half up value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## roundDown

function roundDown(value: decimal): decimal

Returns the integer round down value of the input value.

Parameters :

value: the input value.

Return :

the round down value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## roundHalfDown

function roundHalfDown(value: decimal): decimal

Returns the integer round half down value of the input value.

Parameters :

value: the input value.

Return :

the round half down value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## roundHalfEven

function roundHalfEven(value: decimal): decimal

Returns the integer round half even value of the input value.

Parameters :

value: the input value.

Return :

the round half even value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## roundUp

function roundUp(value: decimal): decimal

Returns the integer round up value of the input value.

Parameters :

value: the input value.

Return :

the round up value of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## scaleByPowerOfTen

function scaleByPowerOfTen(value: decimal, power: decimal): decimal

Returns the value scale by power of ten.

Parameters :

value: the input value.

power: the power of ten that the value will be scale to to. Must be an integer.

Return :

the input value scaled by the power of ten or null if input value or power is null.

Can be used in: Script tasks, Table triggers, Function fields

## sin

function sin(value: decimal): decimal

Returns the trigonometric sine of an angle.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Special cases:

If the input value is zero, then the result is a zero.

Parameters :

value: the input value in radians.

Return :

the sine of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## sqrt

function sqrt(value: decimal): decimal

Returns the positive square root of a value.

Calculations use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value. Must be positive or null.

Return :

the positive square root of the input value or null if input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## tan

function tan(value: decimal): decimal

Returns the trigonometric tangent of an angle.

Special cases:

If the input value is zero, then the result is a zero.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value in radians.

Return :

the tangent of the input value or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## toDegrees

function toDegrees(value: decimal): decimal

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

The conversion from degrees to radians is generally inexact.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value in radians

Return :

the measurement of the input value in degrees or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

## toRadians

function toRadians(value: decimal): decimal

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

The conversion from radians to degrees is generally inexact;

users should not expect cos(toRadians(90.0)) to exactly equal 0.0.

Calculations are executed after conversion in double and use double-precision 64-bit IEEE 754 floating point.

Parameters :

value: the input value in degrees

Return :

the measurement of the input value in radians or null if the input value is null.

Can be used in: Script tasks, Table triggers, Function fields

Documentation > Developer Guide > EBX® Script > API