Constants can take the form of integer, floating-point of string values.
For integers it is possible to specify the value in decimal, binary, octal or hexadecimal notation. This is done by adding 2#, 8# or 16# before the actual value.
Floating-point constants are identified with a decimal '.' indicator, such as: '55.00' or just '55.'
The differentiation is important as '55' will be treated as a integer value whether 55.0 will be treated as a floating-point value.
When defining integer or floating-point constants, it is possible to include '_' (underscore) at any position in the number to enhance readability.
Example:
INCLUDE rtcu.inc
VAR
var : INT;
varf : FLOAT;
END_VAR;
PROGRAM test;
BEGIN
var := 4711;
var := 47_11;
var := 2#10_0010;
var := 8#476;
var := 16#2F32;
varf := 4711.0;
varf := 4_711.56;
END;
END_PROGRAM;
|