Built-in functions: math_min()
The function math_min() estimates the lowest value.
Declaration
Form 1:
int32 math_min( int32 aValue1, int32 aValue2, ... )
uint32 math_min( uint32 aValue1, uint32 aValue2, ... )
int64 math_min( int64 aValue1, int64 aValue2, ... )
uint64 math_min( uint64 aValue1, uint64 aValue2, ... )
float math_min( float aValue1, float aValue2, ... )
char math_min( char aValue1, char aValue2, ... )
Form 2:
point math_min( point aValue1, point aValue2, ... )
rect math_min( rect aValue1, rect aValue2, ... )
color math_min( color aValue1, color aValue2, ... )
Parameters
aValue1, aValue2, ...
The values to evaluate and estimate the minimum.
Discussion
The function math_min() evaluates the values passed in its parameters and returns the lowest one. In its first form the function simply compares the passed numbers and selects the lowest one. For example:
var float min1 = math_min( 1.0, 5.7, -9.7, -13.9 ); // min1 = -13.9 var char min2 = math_min( 'A', 'F', 'Z', 'G' ); // min2 = 'A'
The second form accepts parameters of more complex data types containing multiple components each. For example, an operand of type point contains the components x and y. In this case the function compares the passed values component-wise selecting individually from each component the lowest one. Similarly, with color operands, the function selects the lowest values for the red, green, blue and alpha color components. For example:
var point min1 = math_min( <1,8>, <5,2>, <-9,-10>, <-13,12> ); // min1 = <-13,-10> var color min2 = math_min( #12345678, #AA23CCFF, #45341122 ); // min2 = #12231122
All forms of the function math_min() expect at least two parameters. The given parameters must be of the same data type with the first parameter determining also the resulting data type of the entire operation.