TRUNC_SINT block
Short summary
Name |
TRUNC_SINT |
→POU type |
|
Category |
|
Conform to →IEC-standard |
no restrictions |
Graphical interface |
|
Available since |
|
Functionality
The mathematical function trunc is called:
The decimal portion of the floating-point number connected to input IN is truncated (there is no rounding). The block returns the integer value as SINT value.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN |
REAL, LREAL |
value to truncate |
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, result4, result5, result6, result7, result8 : SINT;
END_VAR
result1 := TRUNC_SINT(
2.8
); (* The variable
'result1'
evaluates to
'2'
. *)
result2 := TRUNC_SINT(
2.5
); (* The variable
'result2'
evaluates to
'2'
. *)
result3 := TRUNC_SINT(
2.01
); (* The variable
'result3'
evaluates to
'2'
. *)
result4 := TRUNC_SINT(
2.0
); (* The variable
'result4'
evaluates to
'2'
. *)
result5 := TRUNC_SINT(-
2.0
); (* The variable
'result5'
evaluates to
'-2'
. *)
result6 := TRUNC_SINT(-
2.3
); (* The variable
'result6'
evaluates to
'-2'
. *)
result7 := TRUNC_SINT(-
2.5
); (* The variable
'result7'
evaluates to
'-2'
. *)
result8 := TRUNC_SINT(-
2.99
); (* The variable
'result8'
evaluates to
'-2'
. *)
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.