min()
The mathLib.min() system function returns the lesser of two numbers (or numeric expressions).
When the two numbers are different types, EGL promotes the smaller type (in terms of bytes) to the larger. For example, if you compare a BIGINT to a FLOAT, EGL compares the numbers as FLOATs, and returns the smaller as a FLOAT. If you then assign the return value to a non-floating point variable, a rounding error might occur.
Syntax
mathLib.min(
numericVariable1 SMALLINT | INT | BIGINT |
DECIMAL | SMALLFLOAT | FLOAT in,
numericVariable2 SMALLINT | INT | BIGINT |
DECIMAL | SMALLFLOAT | FLOAT in)
returns (result SMALLINT | INT | BIGINT |
DECIMAL | SMALLFLOAT | FLOAT)
- numericVariable1
- Input can be any of the numeric variables (or equivalent expressions) shown above.
- numericVariable2
- Input can be any of the numeric variables (or equivalent expressions) shown above.
- result
- The lesser of either numericVariable1 or numericVariable2. If numericVariable1 is a different type than numericVariable2, the type of the returned value is that of the larger of the two types (in terms of bytes).
Example
package com.companyb.customer;
Program calc2
Function main()
x DECIMAL(9,6) = 5.123456;
y FLOAT = 1.11111111111;
result ANY;
result = mathLib.min(x,y);
writeStdOut(result);
// result = 1.11111111111, type is FLOAT
end // main()
end // program