Working with numbers and arithmetic
About this task
In general, you can view COBOL numeric data as a series of decimal digit positions. However, numeric items can also have special properties such as an arithmetic sign or a currency sign.
To define, display, and store numeric data so that you can perform arithmetic operations efficiently:
- Use the
PICTUREclause and the characters9,+,-,P,S, andVto define numeric data. - Use the
PICTUREclause and editing characters (such asZ, comma, and period) along withMOVEandDISPLAYstatements to display numeric data. - Use the
USAGEclause with various formats to control how numeric data is stored. - Use the numeric class test to validate that data values are appropriate.
- Use
ADD,SUBTRACT,MULTIPLY,DIVIDE, andCOMPUTEstatements to perform arithmetic. - Use the
CURRENCY SIGNclause and appropriatePICTUREcharacters to designate the currency you want.