There are three types of number formats (that I'm aware
of): DISPLAY, PACKED-DECIMAL (or COMPUTATIONAL-3 aka COMP-3), and BINARY.
A D V E R T I S E M E N T
are defined in the data division after the PIC clause (although DISPLAY format
is default so you don't really have to define it). In DISPLAY format (aka
character format) a single digit (i.e. PIC 9) would use 1 byte (8 bits) of
memory. In order to save space and processing time, calculation can be performed
in a more economical way using COMP-3 or BINARY formats. This is because they
use less bytes:
01 ITEM-1 PIC 9(3) VALUE 123 USAGE IS DISPLAY.
This uses 4 bytes of memory: one for each digit plus one for the sign (+ or -).
01 ITEM-1 PIC 9(3) VALUE 123 USAGE IS PACKED-DECIMAL.
This uses 2 bytes: each individual digit is converted to binary -
1 2 3 sign
0001 0010 0011 1111 (unsigned)
01 ITEM-1 PIC 9(3) VALUE 123 USAGE IS BINARY. This uses 1
byte: 123 (one-hundred and twenty-three) is converted into binary: 01111011
These compressed formats can be used for calculations but not
much use for displaying or printing the result. Hence, it is necessary to
convert the result of such a calculation back into DISPLAY format:
000100 01 NUMBER-1 PIC 9(3) USAGE IS BINARY.
000110 01 NUMBER-2 PIC 9(3) USAGE IS BINARY.
000120 01 ANSWER-OUT PIC 9(4) USAGE IS DISPLAY.
000200 MULTIPLY NUMBER-1 BY NUMBER-2 GIVING ANSWER-OUT
000210 DISPLAY ANSWER-OUT
Both 'USAGE' and 'IS' are optional (as is 'DISPLAY').