Character-Hybrid Encoding : Zoned Decimal


Zoned (or "Zoned Decimal") is a common numeric encoding system used on IBM mainframes based on the EBCDIC codes (and the old Hollerith punch card "sign-overpunch" concept). It is a common COBOL encoding form used for values for which character input and output is a more significant factor than calculations.

A "Zoned Decimal" encoded value has the form




Character-Hybrid Encoding : Packed Decimal)


Zoned Decimal encoding is used as the basis for Packed Decimal encoding scheme.

The relative merits of Zoned Decimal, Packed Decimal, and 2's Complement encoding are discussed relative to computations, data storage requirements, and character IO.

Zoned and Packed Decimal are basically restricted to IBM mainframe computers (and their "clones"). Other systems often use a system called BCD encoding to get the same advantages as the Packed Decimal system.


Packed Decimal Encoding

The decimal value -91:



Comparative Evaluation

...... note: the IBM mainframe does not support Unsigned Binary

Conversion Process

for EBCDIC input, arithmetic processing, then EBCDIC output (actual time required to perform each step will vary considerable between different IBM mainframe computer systems; "relative timings are given to provide a "feel" for the advantage/disadvantage of conversion to/from Binary):




BCD Encoding

Many non-"IBM mainframe" computer system use a decimal encoding scheme similar to IBM's packed decimal form. This is especially true of spreadsheet package software where continual decimal character IO outweighs the actual computational activities. This system is in general refered to as Binarary Coded Decimal (BCD). BCD suffers from a lack of standardization in the encoding of signed values.
     32 (hex) ...representing 32(dec)
   + 16 (hex) ...representing 16(dec)
   _________  performed with normal (binary) addition
     48 (hex) ...no problem!
      
     38 (hex) ...representing 38(dec)
   + 16 (hex) ...representing 16(dec)
   _________  performed with normal (binary) addition
     4E (hex) ...problem which is easily detected since the
(low-order) 4-bit pattern does not contain a decimal value (solution
is to subtract 10dec and add 10hex, or simply add 6) whenever the
low-order "nybble" contains a value greater than 9)
     
     38 (hex) ...representing 38(dec)
   + 19 (hex) ...representing 19(dec)
   _________  performed with normal (binary) addition
     51 (hex) ...problem which is not easily detected since the
(low-order) 4-bit pattern appears to be valid; because of this
possibility, it may not be possible to perform addition of a pair of
BCD values without splitting the values into single decimal units
(unless, as with the Intel 80x86 processors, an additional "Auxiliary
Carry" flag is provided to indicate that a carry occurred from the
low-order decimal position into the high order decimal position