5.1 Type Conversion Functions
5.1.15 Single-precision real type
→
word (signed), double word (signed) type conversion
5-47
5
APPLICATION
FUNCTIONS
REAL_TO_INT(_E),
REAL_TO_DINT(_E)
REAL_TO_INT(_E), REAL_TO_DINT(_E)
Operation Error
An operation error occurs in the following cases.
• REAL_TO_INT(_E): The input value is outside the range of −32768 to 32767.
(Error code: 4100)
• REAL_TO_DINT(_E): The input value is outside the range of −2147483648 to
2147483647. (Error code: 4100)
Program Example
(1) The program which converts single-precision real type data input to into word (signed)
type data, and outputs the operation result from .
(a) Function without EN/ENO (REAL_TO_INT)
[Structured ladder]
[ST]
g_int1:= REAL_TO_INT(g_real1);
(b) Function with EN/ENO (REAL_TO_INT_E)
[Structured ladder]
[ST]
g_bool3 := REAL_TO_INT_E(g_bool1, g_real1, g_int1);
(2) The program which converts single-precision real type data input to into double word
(signed) type data, and outputs the operation result from .
(a) Function without EN/ENO (REAL_TO_DINT)
[Structured ladder]
[ST]
g_dint1:= REAL_TO_DINT(g_real1);
s
d
s
d