Skip to content
COBOL

Packed decimal

A compact way of storing numbers, two digits per byte, used heavily for amounts in business records.

Also written COMP-3, comp-3, decimal

Packed decimal, declared in COBOL as COMP-3, stores a number as digits rather than as a binary value, packing two digits into each byte with the sign in the last half-byte.

It exists because business data is decimal. Money has exactly two decimal places and must not drift, and packed decimal arithmetic gives exact decimal results with no conversion and no floating-point surprises. Mainframe hardware performs arithmetic on this format directly, so it is fast as well as accurate.

It is also compact. A nine-digit signed amount takes five bytes instead of nine, which mattered enormously when storage was expensive and still matters when you are reading a hundred million records.

The catch is that packed fields are not readable text. Displaying one without converting it produces nonsense on screen, and this surprises everyone the first time they browse a file containing amounts.

COBOL offers other computational formats too, binary and floating point among them, but for currency and quantities in business records, packed decimal is the one you will meet constantly.

Browse all 115 terms

Learn this properly.

Use Packed decimal for real in Mainframe101, in your browser, with Zed beside you. Join the waitlist.

Early access and updates. No spam, unsubscribe any time.