Zoned decimal
The default way COBOL stores numbers: one digit per byte, readable as text, with the sign hidden in the last byte.
Also written USAGE DISPLAY, display numeric, signed numeric, overpunch
Zoned decimal is the default format for a COBOL number, used when a field like PIC S9(5) has no USAGE clause. Each digit takes one byte and is stored as the character for that digit, so the number is readable when you browse the data.
The sign is stored inside the last byte rather than in a separate one. In EBCDIC, that changes the last character. A positive 123 often appears as 12C, and a negative 123 as 12L. An unsigned number shows plain digits. Once you know this, the strange letters at the end of numbers in a file make sense.
Zoned decimal is easy to read but slow to calculate with, so the program converts it to another format first. If the field contains something that is not a valid number, such as spaces from a record that was never filled in, that conversion fails with an S0C7 abend.
Zoned fields are common in files that people need to read or that other systems produce. For fields used mostly in arithmetic, packed decimal is usually chosen instead.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- Packed decimalA compact way of storing numbers, two digits per byte, used heavily for amounts in business records.
- PICTURE clauseThe COBOL declaration that says what kind of data a field holds and how long it is, written as PIC.
- EBCDICThe character encoding mainframes use, where letters and numbers are stored as different byte values than on a laptop.
- Binary fieldA COBOL number stored as a binary integer, written with USAGE COMP, COMP-4, BINARY or COMP-5.
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.