COBOLbeginner

COBOL Data Types: PIC Clauses, COMP and COMP-3

Know how COBOL declares data storage and why COMP-3 packed decimal is the default choice for numeric fields on the mainframe.

COBOL has no primitive int or float keywords — every field's shape and storage format is described by a PICTURE (PIC) clause combined with a USAGE clause. This is one of the fastest ways an interviewer separates candidates who've only read about COBOL from those who've actually maintained it, because picture clauses drive both correctness and performance.

DISPLAY is like writing each digit of a number on its own index card — clear to read but bulky to carry; COMP-3 is like folding two digits onto every card, half the stack, still perfectly legible if you know the fold.

Key Concepts

1
A plain PIC 9(5) field is DISPLAY usage by default — each digit stored as one full byte (zoned decimal), which is human-readable in a hex dump but wastes space. COMP (binary/COMPUTATIONAL) stores the value as a true binary integer, using 2, 4, or 8 bytes depending on digit count, and is fastest for arithmetic. COMP-3 (packed decimal) squeezes two digits per byte plus a nibble for the sign, roughly halving storage compared to DISPLAY while remaining exact for decimal arithmetic — which is why it's the default for money and financial calculations across the industry.
PIC 9(5)COMPCOMP-3
2
Choosing the wrong usage has real consequences: DISPLAY fields are safe for I/O and printing but bloat file sizes and slow arithmetic; COMP is fast but can introduce binary rounding surprises if misunderstood; COMP-3 balances both concerns and is what you'll see in the vast majority of production COBOL copybooks for monetary and quantity fields.
3
Interviewers will often ask you to compute the storage length of a PIC clause under each usage, or to explain why a REDEFINES over a COMP-3 field looks like garbage when viewed as DISPLAY — both are really testing whether you understand that the same nine digits can occupy 9, 5, or 4 bytes depending entirely on USAGE.