Syntax rules
The COMPUTATIONAL-3 and PACKED-DECIMAL phrases are identical in meaning.
The phrases indicate that the data item is stored in internal decimal format (i.e. in packed form).
The PICTURE clause of a COMPUTATIONAL-3 or PACKED-DECIMAL item may contain no characters other than 9s, the operation sign S, the assumed decimal point V, and one or more Ps (see section "PICTURE clause").
General rule
Internal decimal data items are represented by 2 digits per byte; the sign is contained in the four low-order bits of the low-value byte.
For internal decimal data items whose PICTURE clause contains no S, the represen-tation of the absolute value corresponds to the number.
For examples of the COMPUTATIONAL-3 or PACKED-DECIMAL table 17.
Format | PICTURE clause | USAGE and SIGN phrase | Value in external representation | Value in internal | Bytes required | Conversion for arithmetic operation Alignment | Alignment if SYNC is specified |
External | 9999 | DISPLAY | 1234 | F1F2F3F4 | 1 byte/digit | Yes, in order to conform to format of other operands or COMP-3 or PACKED-DECIMAL | |
S9999 | +1234 | F1F2F3C41)2) | |||||
S9999 | -1234 | F1F2F3D41)2) | |||||
S9999 | DISPLAY | 1234+ | F1F2F3C4 | ||||
1234 | F1F2F3D4 | ||||||
S9999 | DISPLAY | 1234+ | F1F2F3F44E | + 1 byte for sign | |||
1234- | F1F2F3F460 | ||||||
S9999 | DISPLAY | +1234 | C1F2F3F4 | ||||
-1234 | D1F2F3F4 | ||||||
S9999 | DISPLAY | +1234 | 4EF1F2F3F4 | + 1 byte for sign | |||
-1234 | 60F1F2F3F4 | ||||||
Internal decimal (packed) | 9999 | COMP-3 | +1234 | 01234F2) | 2 digits per byte, except for low-order byte which contains a digit and the sign | No, except when other operand is binary and conversion to binary would be more advantageous. | None |
9999 | -1234 | 01234F2) | |||||
S9999 | +1234 | 01234C2) | |||||
S9999 | -1234 | 01234D2) | |||||
Binary | S9999 | BINARY | +1234 | 04D2 | 2 bytes for 1-4 digits | No, except when used in mixed-form computations to maintain common formats, or if COMP-3 or PACKED-DECIMAL would be more advantageous. | Halfword |
4 bytes for 5-9 digits | Word | ||||||
8 bytes for 10-18digits | Word | ||||||
16 bytes for 19-31digits | Word | ||||||
S9999 | -1234 | FB2E | 2 | Halfword3) | |||
Ext. | +99.99E-99 | DISPLAY | +12.34E+2 | 4EF1F26BF3F4C540 | 1 byte per | Yes. To internal floating-point | None |
Int. floating point | None allowed | COMP-1 | +12.34E+2 | 434D2000 | 4 | No | Word |
None allowed | COMP-2 | -12.34E-2 | C01F972474538EF3 | 8 | No | Doubleword |
Table 17: Internal representation of internal data items
1) One byte per digit, except for the low-order byte which contains the sign in the first halfbyte and the last digit in the second halfbyte.
2) Mode of sign representation:
F = non-printable plus sign (treated as an absolute value)
C = internal equivalent of plus sign
D = internal equivalent of minus sign.
3) See rules for binary data items.
4) Each character (letter/digit) represents a half byte.