Rules:
decimal point
no space nor thousand separators
sign is optional
Examples:
0
123
-5
+7
0.25
123.456
EXAMPLE FOR USING NUMERIC LITERALS:
Rules:
any amount of characters between " character pairs (not mixed)
the string length is defined by the PIC X(n) field into which the literal will be moved
Examples:
"HELLO"
"12345"
" " (a space)
"" (empty string)
EXAMPLE FOR USING ALPHANUMERIC LITERALS:
In COBOL there is no native boolean type but boolean literal which can be used for level 88 conditions: it defines a level-88 condition name, then renders an alphanumeric literal to it after the VALUE keyword.
See COBOL DATA STRUCTURES for more about level-88.
EXAMPLE FOR USING BOOLEAN LITERALS:
COBOL built-in constants:
ZERO, ZEROS, ZEROES
SPACE, SPACES
HIGH-VALUE, HIGH-VALUES
LOW-VALUE, LOW-VALUES
QUOTE, QUOTES
ALL literal
There are used typically in file-handling (HIGH-VALUE: larger than anything), table initialization (ALL "X"), deletion of text fields (SPACES).
EXAMPLE FOR USING FIGURATIVE CONSTANTS:
These are not literals by COBOL definiton but in practice used as constants (runtime values).
Examples:
RETURN-CODE
TALLY
LENGTH OF identifier
CURRENT-DATE
FUNCTION RANDOM