Number of digits = 2n - 1,
...where n = number of packed input record positions used.
This formula gives you the maximum number of digits you can represent in packed-decimal format; the upper limit is 63.
Zoned-Decimal |
Number of Bytes |
|---|---|
| 1 | 1 |
| 2, 3 | 2 |
| 4, 5 | 3 |
| ⋮ | ⋮ |
| 28, 29 | 15 |
| 30, 31 | 16 |
| ⋮ | ⋮ |
| 60, 61 | 31 |
| 62, 63 | 32 |
For example, an input field read in packed-decimal format has a length of five bytes (as specified on the input or definition specifications). The number of digits in this field equals 2(5) - 1 or 9. Therefore, when the field is used in the calculation specifications, the result field must be nine positions long. The PACKEVEN keyword on the definition specification can be used to indicate which of the two possible sizes you want when you specify a packed subfield using from and to positions rather than number of digits.