VMS Help
COBOL, miscellaneous_topics, literals
*Conan The Librarian
|
A literal is a character-string whose value is specified by:
1) the ordered set of characters it contains, or
2) a reserved word that is a figurative constant.
Every literal belongs to one of two types: numeric or nonnumeric.
Figurative constants name and refer to specific constant values
generated by the compiler. The singular and plural forms of figurative
constants are equivalent and interchangeable. The figurative constants
supported by HP COBOL are ZERO, ZEROS, ZEROES, SPACE, SPACES,
HIGH-VALUE, HIGH-VALUES, LOW-VALUE, LOW-VALUES, QUOTE, QUOTES, ALL
literal, and symbolic-character.
A hexadecimal literal (a HP extension to nonnumeric literals) is
a character string of 2 to 256 hexadecimal digits. It is delimited on
the left by the separator 'X' (or 'x') immediately followed by a
quotation mark (") or apostrophe ('); on the right it is delimited by a
matching quotation mark or apostrophe. The character string consists
only of pairs of hexadecimal digits representing a value ranging from
00 to FF; hence, only the characters '0' through '9', 'A' through 'F',
and 'a' through 'f' are valid.
The value of a hexadecimal literal is the composite value of the paired
hexadecimal representations. The compiler truncates hexadecimal
literals to a maximum of 128 hexadecimal representations (pairs of
hexadecimal digits).
A hexadecimal literal can be used interchangeably wherever a nonnumeric
literal can appear in HP COBOL syntax. (Note that hexadecimal
literals cannot be used as operands in arithmetic statements.)
A nonnumeric literal is a character-string of 0 to 256 characters. It
is delimited on both ends by quotation marks (") or apostrophes ('). A
nonnumeric literal delimited by apostrophes is treated in the same
manner as a nonnumeric literal delimited by quotation marks.
The value of a nonnumeric literal is the value of the characters in the
character-string. It does not include the quotation marks (or
apostrophes) that delimit the character-string. All other punctuation
characters in the nonnumeric literal are part of its value.
The compiler truncates nonnumeric literals to a maximum of 256
characters.
A numeric literal is a character-string of 1 to 33 characters selected
from the digits 0 through 9, the plus sign, the minus sign, and the
decimal point.
The value of a numeric literal is the algebraic quantity represented by
the characters in the literal. Its size equals the number of digits in
the character-string.
|
5 - floating_point_literals
|
A floating point literal is a character-string whose value is specified
by 4 to 37 characters selected from the digits 0 to 9, the plus sign,
the minus sign, the decimal point and the letter E (upper or lower
case).
The value of a floating point literal is the algebraic quantity
represented by the characters in the literal that precede the "E"
multiplied by ten raised to the power of the algebraic quantity
represented by the characters in the literal following the "E".