Skip to main content

Problem:

What is a Zoned Decimal and how is it represented in COBOL?

Resolution:

A zoned decimal is a USAGE DISPLAY item where every digit is represented using one byte character, the corresponding ASCII or EBCDIC character is used for each digit.

If a zoned decimal is Signed and the SIGN clause is not specified (nor the NUMERIC SIGN special-names clause is specified), then the sign is stored in the second part of the last byte together with the last digit, using "C" for postive values or "D" for negative values.

This behaviour can be changed by adding the SIGN clause, ie:

    05 my-zoned-decimal PIC 9(5) USAGE DISPLAY SIGN TRAILING SEPARATE.

The general format is

          

      SIGN [IS] {TRAILING | LEADING} [SEPARATE [CHARACTER]]

Old KB# 2231