
310 A Standard Functions
A.8 Comparison Functions
BOOL
....
ANY
*** GT, >, GE, >=,
LT, <, LE, <=,
EQ, =
***
BOOL
***
*** NE, <>
ANY
ANY
ANY
ANY
stands for:stands for:
Figure A.9. Graphical declarations of the comparison functions GT, GE, LT, LE, EQ, NE
Name Function Description
GT Comparison for „> “ F := 1, if INi > IN(i+1), otherwise 0
GE Comparison for„> =“ F := 1, if INi >= IN(i+1), otherwise 0
LT Comparison for„< “ F := 1, if INi < IN(i+1), otherwise 0
LE Comparison for„< =“ F := 1, if INi <= IN(i+1), otherwise 0
EQ Comparison for„= “ F := 1, if INi = IN(i+1), otherwise 0
NE Comparison for„<>“ F := 1, if INi <> IN(i+1), otherwise 0
Table A.8. Description of the comparison functions
The specification of these standard functions is illustrated in Example A.5 by the
declaration of
GT
in ST, from which the others can easily be derived.
FUNCTION GT : BOOL (* comparison for ‘greater than’ *)
VAR_INPUT IN1, IN2, ... INn : ANY; END_VAR
IF (IN1 > IN2)
AND (IN2 > IN3)
...
AND (IN(n-1) > INn) THEN
GT := TRUE; (* inputs are "sorted": in increasing monotonic sequence *)
ELSE
GT := FALSE; (* condition not fulfilled *)
END_IF;
END_FUNCTION
Example A.5. Specification of the comparison function GT in ST