Truncate (cut off) decimal digits of REAL or LREAL input variable, convert to Unsigned INTEGER
TRUNC_TO_UINT cuts off any digits following the decimal of a REAL, LREAL number and delivers an output variable of the data type Unsigned INTEGER.
Input
input data type
Output
Conversion result
If the decimal digits are cut off, positive numbers will be decreased towards zero and negative numbers will be increased towards zero.
if input variable does not have the data type REAL
if output variable is greater than a 16-bit INTEGER
if output variable is zero
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
UINT_value: UINT:=0;
REAL_value: REAL:=28.5;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,REAL_value,13,2,15,4,);
B(B_VAROUT,,UINT_value,24,2,26,4,);
B(B_F,TRUNC_TO_UINT!,Instance,15,2,24,4,,?D?C);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
UINT_value:= TRUNC_TO_UINT(REAL_value);