assign()

The mathLib.assign() system function assigns the value of a source expression to a target variable, preserving the rounding behavior that was automatic in EGL version 6.

The result is rounded to the number of decimal places that is specified in the variable declaration (where the target type is DECIMAL). The function is typically used in EGL migration, but can be useful when you cannot determine the type of the target variable. For more information about rounding, overflow, and version compatibility, see Rounding and truncation between numeric types.

Syntax

  mathLib.assign(
    source FLOAT | HEX(8) | HEX(16) in
    target SMALLINT | INT | BIGINT | DECIMAL |
             SMALLFLOAT | FLOAT | HEX(8) | HEX(16) out )
source
Input can be a variable or expression that is assignment compatible to any of the following types: FLOAT, HEX(8), or HEX(16).
target
The target variable can be any of the types shown above.

Example

The following expression can result in an overflow:

x DECIMAL(9,2);
y DECIMAL(9,4);
...
x = cos(y);

To ensure that the result is rounded to fit the target variable type, wrap the expression with the mathLib.assign() function:

assign(cos(y), x);

Compatibility

Table 1. Compatibility considerations for assign
Platform Issue
Rich UI The function mathLib.assign() is not supported.

Feedback