COBOL Manual for TNS and TNS/R Programs

Tape Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
27-14
Tape Files of Types Other Than HP
HP COBOL data types:
BINARY or COMPUTATIONAL
BINARY and COMPUTATIONAL are synonyms. HP COBOL stores a
COMPUTATIONAL data item as a 2-byte, 4-byte, or 8-byte binary value,
depending on the number of digits in its picture:
DISPLAY
HP COBOL stores a DISPLAY data item as a sequence of ASCII characters, one
for each digit. If the data description entry specifies that the sign is separate from
the value, a separate byte is allocated for the sign, which is stored as an explicit
plus (+) or a minus (-) character.
If the data description entry does not specify that the sign is separate from the
value, the sign is stored by setting the high-order bit of one byte of the data item—
the high-order byte if the sign is specified as LEADING; the low-order byte
otherwise.
The value zero has neither a positive nor a negative sign.
Some examples of data descriptions and their corresponding stored values are:
Picture Storage
S9(01) - S9(04) 1 byte
S9(05) - S9(09) 2 bytes
S9(10) - S9(18) 4 bytes
Data Description Binary Value Stored
PIC S99 VALUE 5 00110000 00110101
PIC S99 VALUE -5 00110000 10110101
PIC S99 VALUE 0 00000000 00000000
PIC S99 SIGN LEADING VALUE 5 00110000 00110101
PIC S99 SIGN LEADING VALUE -5 10110000 00110101
PIC S99 SIGN LEADING VALUE -0 00000000 00000000
PIC S99 SIGN TRAILING VALUE 5 00110000 00110101
PIC S99 SIGN TRAILING VALUE -5 00110000 10110101
PIC S99 SIGN TRAILING VALUE 0 00000000 00000000