Friday, July 18, 2008

COMPUTE Commands


The COMPUTE assigns the result of an arithmetic expression to a data-item. The arithmetic expression is evaluated according to the normal arithmetic rules. That is, the expression is normally evaluated from left to right but bracketing and the precedence rules shown below can change the order of evaluation.

Precedence Symbol Meaning
1. ** Power
2. * Multiply
/ Divide
3. + Add
- Subtract

Note that unlike some other programming languages COBOL provides the ** expression symbol to represent raising to a power.

No comments: