MainframeMaster

COMP-3 packed decimal converter

Pack a number into COMP-3 hex, or unpack dump bytes back to a value. See the sign nibble, digit layout, and byte length. For PIC sizing without packing, use the PIC storage calculator.

How to use it

  1. Choose Hex → number to decode a dump, or Number → hex to pack a value.
  2. Set decimal places (V scale) when the field has an implied decimal (money, rates).
  3. On pack, optionally set total digits to match your PIC, and choose unsigned (F) vs signed (C/D).

COMP-3 packed decimal converter

Examples

Unpacked value

20261112

Bytes
5
Digit nibbles
9 (020261112)
Sign nibble
F — unsigned / positive
Normalized hex
02 02 61 11 2F
Nibble layout
02 · 02 · 61 · 11 · 2(digit) F(sign=F)

COMP-3 layout

Two digits per byte; the last half-byte is the sign (C +, D −, F unsigned). Byte length is ceil((digits + 1) / 2). Need PIC sizing only? Use the PIC storage calculator.

Need this at work?

Free account saves tutorial progress. The jobs board lists openings that ask for JCL.

COBOL jobs on the board

Sign nibbles

  • C — positive (preferred for signed PIC S9…)
  • D — negative
  • F — unsigned / positive (common for PIC 9… without S)
  • A / B / E — alternate positive codes accepted on unpack

Example

Unsigned date 20261112 packs to five bytes:

text
02 02 61 11 2F

That is digits 020261112 with sign F — the same shape File-AID often labels as something like 5/PS when the field is packed.

Explain it like I'm 5

COMP-3 squeezes two digits into each byte, like sharing bunk beds. The last half-bed is reserved for a tiny plus/minus flag. Hex is just the flashlight view of those packed beds.

Related concepts

Related pages

Related Pages

FAQ

Sources

Encoding follows IBM packed-decimal / COMP-3 conventions: digit nibbles high-order first, trailing sign nibble C/D/F (with tolerant unpack of alternate positive codes).