Several languages support
packed decimal and zoned decimal data. The following table shows how
COBOL picture clauses correspond to SAS formats and informats.
|
Corresponding S370Fxxx
Formats and Informats
|
|
|
|
|
|
|
|
|
PIC S9(W) DISPLAY SIGN
LEADING
|
|
PIC S9(W) DISPLAY SIGN
LEADING SEPARATE
|
|
PIC S9(W) DISPLAY SIGN
TRAILING SEPARATE
|
|
For the packed decimal
representation listed above, X indicates the number of digits represented,
and W is the number of bytes. For PIC S9(X) PACKED-DECIMAL, W is
ceil((x+1)/2)
.
For PIC 9(X) PACKED-DECIMAL, W is
ceil(x/2)
.
For example, PIC S9(5) PACKED-DECIMAL represents five digits. If a
sign is included, six nibbles are needed.
ceil((5+1)/2)
has
a length of three bytes, and the value of W is 3.
Note that you can substitute
COMP-3 for PACKED-DECIMAL.
In IBM assembly language,
the P directive indicates packed decimal, and the Z directive indicates
zoned decimal. The following shows an excerpt from an assembly language
listing, showing the offset, the value, and the DC statement:
offset value (in hex) inst label directive
+000000 00001C 2 PEX1 DC PL3'1'
+000003 00001D 3 PEX2 DC PL3'-1'
+000006 F0F0C1 4 ZEX1 DC ZL3'1'
+000009 F0F0D1 5 ZEX2 DC ZL3'1'
In PL/I, the FIXED DECIMAL
attribute is used in conjunction with packed decimal data. You must
use the PICTURE specification to represent zoned decimal data. There
is no standardized representation of decimal data for the Fortran
or the C languages.