Data Constants

Constants define the value of the data they represent.  A constant can be an alphanumeric, numeric or wide literal, and the value cannot be changed.  

Alphanumeric Literals

Alphanumeric literals are represented by any combination of characters, with a maximum length of 250.  They must be enclosed within single (‘) or double (“) quotes.  The use of two quote types allows for one of them to be used as data within the literal.

‘BY’              Two-character value.
"ACDL"          Four-character value.
"ISN’T"          Five-character value (single quote is part of the alphanumeric literal).
"ACDL"          Invalid––different beginning and ending quotes.

Numeric Literals

Numeric literals are made up of a set of digits (0 - 9) with an optional preceding or trailing (+) or (-) character and an optional decimal point.

15.27                   Valid
201                      Valid
-237.125              Valid
1234.5-                Valid
1E2                      Valid
23+4                    Invalid - embedded sign
2.345w                 Invalid - non-numeric character

Wide Literals

Wide literals may contain only wide (multi-byte) characters and they have a maximum length of 125 characters.  They must be preceded by a "W", and also be enclosed within single or double quotes (e.g. W "A B ‘C").

 

Comment on this topic

Topic ID: 730002