5-50
5.1 Type Conversion Functions
5.1.16 Double-precision real type
→
word (signed), double word (signed) type conversion
LREAL_TO_INT(_E), LREAL_TO_DINT(_E)
Operation Error
An operation error occurs in the following cases.
• The input value is -0 or outside the following range. (Error code: 4140)
0, 2
-1022
| , | 2
1024
• LREAL_TO_INT(_E): The input value is outside the range of -32768 to 32767.
(Error code: 4140)
• LREAL_TO_DINT(_E): The input value is outside the range of -2147483648 to
2147483647. (Error code: 4140)
Program Example
(1) The program which converts double-precision real type data input to into word (signed)
type data, and outputs the operation result from .
(a) Function without EN/ENO (LREAL_TO_INT)
[Structured ladder]
[ST]
g_int1:= LREAL_TO_INT(g_lreal1);
(b) Function with EN/ENO (LREAL_TO_INT_E)
[Structured ladder]
[ST]
g_bool3 := LREAL_TO_INT_E(g_bool1, g_lreal1, g_int1);
(2) The program which converts double-precision real type data input to into double word
(signed) type data, and outputs the operation result from .
(a) Function without EN/ENO (LREAL_TO_DINT)
[Structured ladder]
[ST]
g_dint1:= LREAL_TO_DINT(g_lreal1);
s d
s
d
s
d