matthewstorey.co.uk
In this section Binary Coded Decimal | Binary | Character Numeric Edited | Packed Decimal | Text | Zoned Decimal

Zoned Decimal

About

Values are essentially text (so depend on a codepage) e.g. '1234567890'.

Signed fields have a 'C' (for Credit / +) or a 'D' (for Debit / -) as the first half of the last byte.

Limits:

COBOL programs can only handle a maximum of 18 digits by default, although this can be extended to 31 via the 'ARITH(EXTEND)' compiler option.

Other:

Also known as 'ZD'.

Implied decimal places.

Use:

Used on every platform.

ASCII codepage examples

Unsigned

     12345     is encoded in hex as    33333
                                       12345

     12345.67  is encoded in hex as    3333333
                                       1234567
      

Signed

     +12345    is encoded in hex as    3333C
                                       12345

     -12345.67 is encoded in hex as    333333D
                                       1234567
      

EBCDIC codepage examples

Unsigned

     12345     is encoded in hex as    FFFFF
                                       12345

     12345.67  is encoded in hex as    FFFFFFF
                                       1234567
      

Signed

     +12345    is encoded in hex as    FFFFC
                                       12345

     -12345.67 is encoded in hex as    FFFFFFD
                                       1234567
      

Back to top