Typecast INT(expression)

Top  Previous  Next

The INT typecast operator is used to convert an expression to an INT type. If the typecast operator is used on a "larger" type, truncation will occur. If the typecast is used to convert from a "smaller" type, sign extension will occur.

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : INT;
  b : DINT;
END_VAR;
 
PROGRAM test;
 
// Convert 'b' which is a DINT type to a INT (truncation will occur)
a := INT(b);
 
END_PROGRAM;