Handling of Computation Items
Numeric values in COBOL data are commonly stored in display or character format, (that is, as base-10 numbers, with each digit represented by the corresponding character). For example, a field defined as PIC 999 that contains the value 123 is stored in three bytes, each byte containing one digit of the value.
When performing computation with numbers, machines can perform the computations significantly faster on binary (base-2) numbers that base-10 numbers. Therefore, if a number is stored in a COBOL data in binary format, it can be used in computations directly. You can use versions of COMP (COMP-3 COMP-4, and so on) to change the storage format from text to binary form.
COMP Versus COMP-5
For integer fields in COBOL, COMP specifies the storage of half word, full word, or double word (2, 4, and 8 bytes, respectively). However, an additional limitation is applicable based on the number of decimal digits in the PICTURE clause. For instance, even though PIC S9(4) COMP has a signed half-word storage, it limits the values to the range of -9999 through +9999 due to the four decimal places in the PICTURE clause.
You can use COMP-5 to eliminate the limitation. This usage, though the same as COMP, allows the whole range of values representable by a particular number of storage bytes. For example, PIC S9(4) COMP-5 has a half-word storage and allows the range of values of -32768 through +32767.