SIGN block
Short summary
Name |
SIGN |
→POU type |
|
Category |
|
Conform to →IEC-standard |
not defined in IEC-standard |
Graphical interface |
|
Available since |
version 1.27.0 (for logi.CAD 3) |
Functionality
The block returns information about the sign of the value that is connected to the input IN:
Value connected to IN |
Return value |
< 0 |
-1 |
0 |
0 |
> 0 |
1 |
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
value |
Return value: |
– |
SINT |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Example for usage within ST-editor
PROGRAM Test
VAR
result1, result2, result3 : SINT;
END_VAR
result1 := SIGN(INT#-
5
); (* The variable
'result1'
evaluates to
'-1'
. *)
result2 := SIGN(INT#
0
); (* The variable
'result2'
evaluates to
'0'
. *)
result3 := SIGN(INT#
5
); (* The variable
'result3'
evaluates to
'1'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.