Constant expressions can be used in all languages for assigning a variable with a value. All constant expressions have a well defined data type according to their semantics. If you program an operation between variables and constant expressions having inconsistent data types, it will lead to syntactic errors when the program is compiled. Below are the syntactic rules for constant expressions according to possible data types:

__BOOL: Boolean__

There are only two possible boolean constant
expressions. They are reserved keywords **TRUE** and
**FALSE**.

__SINT: Small (8 bit) Integer__

Small integer constant expressions are valid integer
values(between -128 and 127) and must be prefixed with
"**SINT#**'. All integer expressions having no prefix are
considered as DINT integers.

__USINT / BYTE: Unsigned 8 bit Integer__

Unsigned small integer constant expressions are valid integer
values(between 0 and 255) and must be prefixed with
"**USINT#**'. All integer expressions having no prefix are
considered as DINT integers.

__INT: 16 bit integer__

16 bit integer constant expressions are valid integer
values(between -32768 and 32767) and must be prefixed with
"**INT#**'. All integer expressions having no prefix are
considered as DINT integers.

__UINT / WORD: Unsigned 16 bit integer__

Unsigned 16 bit integer constant expressions are valid integer
values(between 0 and 255) and must be prefixed with "**UINT#**'.
All integer expressions having no prefix are considered as DINT
integers.

__DINT: 32 bit (default) integer__

32 bit integer constant expressions must be valid numbers
between -2147483648 to +2147483647.
DINT is the default size for integers: such constant expressions do
not need any prefix. You can use "**2#**", "**8#**" or
"**16#**" prefixes for specifying a number in respectively
binary, octal or hexadecimal basis.

__UDINT / DWORD: Unsigned 32 bit integer__

Unsigned 32 bit integer constant expressions are valid integer
values(between 0 and 4294967295) and must be prefixed with
"**UDINT#**'. All integer expressions having no prefix are
considered as DINT integers.

__LINT: Long (64 bit) integer__

Long integer constant expressions are valid integer values and
must be prefixed with "**LINT#**'. All integer expressions
having no prefix are considered as DINT integers.

__REAL: Single precision floating point value__

Real constant expressions must be valid number, and
must include a dot ("**.**"). If you need to enter a real
expression having an integer value, add "**.0**" at the end of
the number. You can use "**F**" or "**E**" separators for
specifying the exponent in case of a scientist representation. REAL
is the default precision for floating points: such expressions do
not need any prefix.

__LREAL: Double precision floating point value__

Real constant expressions must be valid number, and must include
a dot ("**.**"), and must be prefixed with "**LREAL#**". If
you need to enter a real expression having an integer value, add
"**.0**" at the end of the number. You can use "**F**" or
"**E**" separators for specifying the exponent in case of a
scientist representation.

__TIME: Time of day__

Time constant expressions represent durations that must be less
than 24 hours. Expressions must be prefixed by either
"**TIME#**" or "**T#**". They are expressed as a number of
hours followed by "**h**", a number of minutes followed by
"**m**", a number of seconds followed by "**s**", and a
number of milliseconds followed by "**ms**". The order of units
(hour, minutes, seconds, milliseconds) must be respected. You
cannot insert blank characters in the time expression. There must
be at least one valid unit letter in the expression.

__STRING: Character string__

String expressions must be written between single quote marks. The length of the string cannot exceed 255 characters. You can use the following sequences to represent a special or not printable character within a string:

$$
$' $T $R $L $N $P $xx |
a "$"
character a single quote a tab stop (ASCII code 9) a carriage return character (ASCII code 13) a line feed character (ASCII code 10) carriage return plus line feed characters (ASCII codes 13 and 10) a page break character (ASCII code 12) any character (xx is the ASCII code expressed on two hexadecimal digits |

__Examples__

Below are some examples of valid constant expressions

TRUE
FALSE SINT#127 INT#2000 123456 16#abcd LINT#1 0.0 1.002E3 LREAL#1E-200 T#23h59m59s999ms TIME#0s T#1h123ms 'hello' 'name$Tage' 'I$'m here' 'x$00y' |
TRUE
boolean expression FALSE boolean expression small integer 16 bit integer DINT (32 bit) integer DINT integer in hexadecimal basis long (64 bit) integer having the value "1" 0 expressed as a REAL number 1002 expressed as a REAL number in scientist format Double precision real number maximum TIME value null TIME value TIME value with some units missing character string character string with two words separated by a tab character string with a quote inside (I'm here) character string with two characters separated by a null character (ASCII code 0) |

Below are some examples of typical errors in constant expressions

BooVar := 1;
1a2b 1E-200 T#12 'I'm here' hello |
0 and 1
cannot be used for booleans basis prefix ("16#") omitted "LREAL#" prefix omitted for a double precision float Time unit missing quote within a string with "$" mark omitted quotes omitted around a character string |