COBOL Manual for TNS and TNS/R Programs
Procedure Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
8-46
Arithmetic Expressions
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 8-13 must be preceded and followed by a separator (usually
spaces or parentheses).
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.
Table 8-13. Arithmetic Operators
Operator
MeaningSymbol Kind
+ Unary Multiplication by +1
Binary Addition
- Unary Multiplication by -1
Binary Subtraction
* Binary Multiplication
/ Binary Division
** Binary Exponentiation