COBOL Manual for TNS and TNS/R Programs
Language Elements
HP COBOL Manual for TNS and TNS/R Programs—522555-006
3-17
Literals
Decimal Numeric Literals
A decimal numeric literal is a character-string that has the value of the sequence of its
digits.
digits
is a string of one to 18 digits. The total number of digits in a decimal numeric literal
cannot exceed 18.
dp
is a decimal point. It is a period (“.”) unless the program contains the DECIMAL
POINT COMMA phrase in the SPECIAL-NAMES paragraph, in which case it is a
comma (“,”).
Decimal numeric literals follow these rules:
•
When a decimal numeric literal appears in a context where its value is assumed to
be a sequence of characters, its size is equal to the number of digits in its
representation.
•
A sign character (+ or -) has no effect on the size of a literal. Absence of a sign
signifies a positive number.
•
COBOL does not permit the decimal point as the rightmost (last) character;
HP COBOL relaxes this restriction somewhat:
°
If the apparent last character of a numeric literal qualifies as a decimal point
and the immediately following character is not a space (but is a semicolon,
comma, or right parenthesis), the compiler interprets that last character as the
decimal point.
°
If the apparent last character qualifies as a decimal point but the immediately
following character is a space, the compiler interprets that last character and
the space together as the separator that follows the literal.
•
The compiler interprets a decimal point as an assumed decimal point; that is, the
character is not present in the value even if the context of the literal implies that the
value is represented as a sequence of characters.
•
A decimal numeric literal that has no decimal point is an integer.
digits
digits
ns
digits
ns
+
-
dp
ns
dp
ns
VST743.vsd