Calculation Engine Math Functions

The following are common mathematical functions to be used in the OAS Calculation Engine:

Absolute

Returns absolute value of the input

Parameters:

  • Value to convert to absolute value

Example:

ABS([Tag.Value]) 
// ABS(-1) returns 1 
// ABS(1) returns 1 

Add

Addition operator placed between two numeric values, returning the sum

Example:

[Tag1.Value] + [Tag2.Value] 

BCD to Integer

Converts binary coded decimal to integer value.

Parameters:

  • BCD value to convert

Example:

BCDINT([Tag.Value]) 

Divide

Division operator placed between two numeric values, returning the result

Example:

[Tag1.Value] / [Tag2.Value] 

Exponent

Returns e raised to the specified power.

Parameters:

  • Value to use as the exponent

Example:

EXP([Tag.Value]) 

Hex to Integer

Converts a hexadecimal string to an integer.

Parameters:

  • Value to convert

Example:

HEXINT([Tag.Value]) 
// "3" converts to 3 
// "F" converts to 15 
// "F3" converts to 243 

Integer to Hex

Converts an integer to hexadecimal.

Parameters:

  • Value to convert

Example:

INTHEX([Tag.Value]) 
// 3 converts to "3" 
// 15 converts to "F" 
// 243 converts to "F3" 

Integer Divide

Integer division operator between two numeric values, returning the integer component of the result

Example:

[Tag.Value] % 3 
// 33 % 3 returns 11 
// 35 % 3 also returns 11 

Integer to BCD

Converts an intgeger to a binary coded decimal.

Parameters:

  • Integer value to convert

Example:

INTBCD([Tag.Value]) 

Integral Power

Returns a specified number raised to the specified power.

Parameters:

  • Value to be raised to a power
  • The power

Example:

INTPOW([Tag.Value],6) 

LN

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

Parameters:

  • Value to convert

Example:

LN([Tag.Value]) 

LOG

Returns the base 10 logarithm of a specified number

Parameters:

  • Value to convert

Example:

LOG([Tag.Value]) 

LOGN

Returns the base logn of a specified number.

Parameters:

  • Value to convert
  • Base

Examples:

LOGN([Tag.Value], 2) 
LOGN([Tag.Value], [Tag2.Value]) 
LOGN(100, [Tag.Value]) 

Median

Returns median value from multiple values. If an even number of values then it returns the average of the middle 2 numbers.

Parameters:

  • A list of values to evaluate in the median calculation

Examples:

MEDIAN([Tag1.Value],[Tag2.Value]) 
MEDIAN([Tag1.Value],[Tag2.Value],[Tag3.Value]) 
MEDIAN([Tag1.Value],[Tag2.Value],[Tag3.Value],[Tag4.Value],[Tag5.Value]) 

Modulo

Returns the modulus of parameter 1 with parameter 2 value applied.

Parameters:

  • Number to evaluate
  • Operator

Examples:

MOD([Tag.Value],3) 
MOD(100,[Tag.Value]) 
MOD([Tag1.Value],[Tag2.Value]) 

Multiply

Multiplication operator placed between two numeric values, returning the result

Example:

[Tag1.Value] * [Tag2.Value] 

Negate

Placed before a numeric value, returns the negative value. If placed before a negative value, will return a positive result.

Example:

- [Tag.Value] 

Power

Returns a specified number raised to the specified power.

Parameters:

  • Number to be raised to a power
  • The power

Example:

POW([Tag.Value],4) 
POW(2,[Tag.Value]) 

Sign

Returns 1 if value is greater than 0. Returns -1 if less than 0. Returns 0 if equal to 0.

Parameters:

  • Value to evaluate.

Examples:

SIGN([Tag.Value]) 

Square

Returns the square of a specified number.

Parameters:

  • Value to convert.

Example:

SQR([Tag.Value]) 

Square Root

Returns the square root of a specified number.

Parameters:

  • Value to convert.

Example:

SQRT([Tag.Value]) 

Subtract

Subtraction operator placed between two numeric values, returning the difference

Example:

[Tag1.Value] - [Tag2.Value] 

Sum

Summation of all values supplied.

Parameters:

  • List of values to sum. As many parameters as you desire.

Example:

SUM([Tag1.Value],[Tag2.Value]) 
SUM([Tag1.Value],[Tag2.Value],[Tag3.Value]) 
SUM(100,[Tag1.Value],[Tag2.Value],[Tag3.Value],[Tag4.Value])