<INT type>_TO_<INT type>
This IEC operator converts from one integer data type to another integer data type.
Syntax: <INT data type>_TO_<INT data type>
Integral data types:
- BYTE
- WORD, DWORD, LWORD
- SINT, INT, DINT, LINT
- USINT, UINT, UDINT, ULINT
Information may be lost during type conversion from larger to smaller data types. If the number to be converted exceeds the range bound, TwinCAT ignores the first bytes of the number. |
Samples:
Result: nVar is 127.
ST:
nVar := INT_TO_SINT(4223);
If you save the integer number 4223 (16#107f in hexadecimal representation) in a SINT variable, this variable contains the number 127 (16#7f in hexadecimal representation).
FBD:
See also:
- Data types > Integer Data Types