COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Operands
An operand is a numeric literal, the identifier of a numeric data item, or any arithmetic expression
enclosed within balanced left and right parentheses. The identifiers and literals appearing in an
arithmetic expression must represent numeric data items and numeric literals upon which arithmetic
can be performed.
Arithmetic Operators
Each operator in Table 50 must be preceded and followed by a separator (usually spaces or
parentheses).
Table 50 Arithmetic Operators
Operator
MeaningKindSymbol
Multiplication by +1Unary+
AdditionBinary
Multiplication by -1Unary-
SubtractionBinary
MultiplicationBinary*
DivisionBinary/
ExponentiationBinary**
The minus sign (-) and the plus sign (+) must be preceded by a space or a left parenthesis and
followed by a space. The exponentiation sign (**) cannot contain an embedded space, but it can
be split across two lines through the use of the hyphen continuation character.
A plus (+) or minus (-) appearing as the first character of a numeric literal is the sign character of
that literal, not an arithmetic operator. For example, +2 is not an arithmetic expression. In contrast,
a plus (+) or minus (-) followed by a separator is interpreted as a binary operator when preceded
by an operand or as a unary operator when not preceded by an operand. For example, X + 2
represents a simple arithmetic expression. The presence of a sign character in a numeric literal
does not affect its use as an operand; therefore, both X + + 2 and X + 2 are valid and, in this
case, equivalent expressions.
Formation and Evaluation Rules
Parentheses can be used to specify the order in which the elements of an expression are to be
evaluated. Expressions within parentheses are evaluated first. Within nested parentheses, evaluation
proceeds from the least inclusive set to the most inclusive set. When parentheses are not used, or
parenthesized expressions are at the same level of inclusiveness, the hierarchical order of execution
is shown in Table 51.
Table 51 Hierarchy of Operators
OperatorsHierarchy
Unary plus and minus1st
Exponentiation2nd
Multiplication and division3rd
Addition and subtraction4th
When no parentheses are present to specify otherwise, the order of execution of consecutive
operations of the same hierarchical level is from left to right.
260 Procedure Division