MathLib.min function

MathLib.min returns the lesser of two numeric values.

Package

eglx.lang

Syntax
	static function min(val1 smallint in, val2 smallint in) returns(smallint);

	static function min(val1 int in, val2 int in) returns(int);

	static function min(val1 bigint in, val2 bigint in) returns(bigint);

	static function min(val1 float in, val2 float in) returns(float);

	static function min(val1 smallfloat in, val2 smallfloat in) returns(smallfloat);

	static function min(val1 decimal in, val2 decimal in) returns(decimal);
val1, val2
The first and second numeric values to be compared.

When the two numbers are of different types, EGL promotes the one with fewer bytes to the larger. For example, if you compare a BIGINT to a FLOAT, EGL compares the numbers as FLOATs and returns the smaller of the two as a FLOAT. A rounding error might occur if you assign the FLOAT to a variable of another type.

Example use

After the following code runs, the value of result is 1.111111 and the type is FLOAT:

x DECIMAL(9,6) = 1.111111;
y FLOAT = 5.123456;
result ANY = mathLib.min(x,y);
Comments

In the case of Java™, EGL uses methods in the Java StrictMath class that are equivalent to the EGL functions. This usage ensures that the runtime behavior is the same for every Java Virtual Machine.

Compatibility

Table 1. Compatibility
Target Issue
Java No issues.
JavaScript No issues.