The COMPUTE statement calculates the value of an arithmetic expression and assigns the value to one or more data items.

COMPUTE Statement

identifier-1 must refer to either an elementary numeric item or an elementary numeric edited item.

An arithmetic expression consisting of a single identifier or literal provides a method of setting the value of identifier-1 equal to the value of the single identifier or literal.

The COMPUTE statement allows the user to combine arithmetic operations without the restrictions on composite of operands, receiving data items, or both, imposed by the arithmetic statements ADD, SUBTRACT, MULTIPLY and DIVIDE.

Additional rules and explanations regarding features of the COMPUTE statement that are common to other arithmetic statements can be found in the discussion of common rules. See in particular the discussions of the ROUNDED phrase, the size error condition, overlapping operands, modes of operation, composite size, and incompatible data.

COMPUTE Statement Examples

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

COBOL Topics