Monday, 28 July 2014

COBOL COMP-3 or Packed-Decimal.

In this format, the digit bits in the rightmost byte hold the sign of the number and the zone bits in that byte hold the rightmost digit in the number. 

All other bytes hold two digits each. As a result, each packed-decimal number has an odd number of digits and a sign.

Packed-decimal format (Packed-Decimal or Comp-3 usage)

  00 12 3F              Unsigned number with a value of 123
  00 12 3C              Positive number with a value of +123
  00 12 3D              Negative number with a value of -123

Format : 

This format is most efficient when you code an odd number of digits in the PICTURE description, so that the leftmost byte is fully used. Packed-decimal items are handled as fixed-point numbers for arithmetic purposes.

Example : 



Created with Artisteer

No comments:

Post a Comment