iDevOS CALC "MIN" Command
Get the minimum value from a set of variables or an array of variables.
Description
CALC( y, a, b, "MIN" ); // y = min(a, b) = minimum of a, b CALC( y, a, b, c, "MIN" ); // y = min(a, b, c) = minimum of a, b, c CALC( y, array, "MIN" ); // y = min(array) = minimum value in array
If the parameters passed to this command are two or three individual variables (a
, b
, c
) then this command returns the minimum value y
of these variables. If an array
is passed to this command then the returned value y
is the minimum value found in the array
.
See "MAX"
to get the maximum value.
Parameters
y
- Calculation result.
Parameter type: entity name of a numeric variable (egU8
,S32
,FLT3
etc). a
,b
andc
- Input values.
Parameter type: immediate number, or entity name of a numeric variable (egU8
,S32
,FLT3
etc). - Input array.
Parameter type: entity name of a numeric array (egU8
array,S32
array,FLT3
array etc). "MIN"
- CALC command operator.
Parameter type: immediate string.
Examples
Example 1
VAR(d, 0, S32); CALC(d, 10, 20, "MIN"); // d = 10 CALC(d, 100, -69, 5, "MIN"); // d = -69
Example 2
VAR(arr, 0, S8, 6); // create array of size 6 VAR(res, 0, S8); // result // Initialise array: arr = { 5, -12, 0, 90, -15, 0 } LOAD(arr.0, 5); LOAD(arr.1, -12); LOAD(arr.3, 90); LOAD(arr.4, -15); CALC(res, arr, "MIN"); // res = -15