Stratus COBOL or VoS COBOL -Comp-4 Vs Comp-5 and Comp-6

COBOL Comp-1 Vs Comp-2
COBOL Comp-1 Vs Comp-2

VOS COBOL supports short and long fixed-point binary integer data formats described in this section, as well as a decimal scaled binary data format.

•comp-4 is the VOS COBOL short integer data format.

•comp-5 is the VOS COBOL long integer data format.

•comp-6 is the VOS COBOL scaled fixed-point data format.

comp-4 Data

comp-4 is fixed-point binary data with 15-bit precision, word-aligned, and stored in two bytes. The scaling factor is zero. Values are stored in two’s complement form.

For integer data, such as counters and switches that do not require values outside the range -32,768 to +32,767, use comp-4 data.

comp-4 data is described with the usage clause. It does not require a picture. If a picture clause is specified, it must describe signed data with no more than four digits to the left of the decimal point and none to the right. If no valid picture is specified, a maximum of 15 bits of precision is assumed.

If the on size error phrase is specified, the statements following the phrase are executed only if the arithmetic operation results in a value either greater than 32,767 or less than -32,768.

comp-5 Data

comp-5 is fixed-point binary data with 31-bit precision, word-aligned, and stored in four bytes. The scaling factor is zero. Values are stored in two’s complement form.

For integer data values greater than 32,767 (but less than 2,147,483,646) or less than -32,768 (but greater than -2,147,483,647), use comp-5 data.

comp-5 data is described with the usage clause. It does not require a picture. If a picture clause is specified, it must describe signed data with no more than nine digits to the left of the decimal point and none to the right. If no valid picture is specified, a maximum of 31 bits of precision is assumed.

If the on size error phrase is specified, the statements following the phrase are executed only if the arithmetic operation results in a value either greater than 2,147,483,646 or less than -2,147,483,647.

comp-6 Data

comp-6 is variable-length binary encoded data with internal decimal scaling. It is word-aligned and stored in either four bytes or eight bytes, depending on the number of digits described in the item’s picture clause. This type of data can hold any value which can be represented by a VOS COBOL picture (up to 18 decimal digits).

Note: Specifying binary in the usage clause produces the same results as if comp-6 were specified.

comp-6 data is the recommended format for noninteger or very large (+ or -) computational values (containing up to 18 digits).

comp-6 data descriptions require a picture clause. The compiler determines the storage requirements of a comp-6 data item based on the picture. Also, the number of digits in the picture clause determines the point at which a size error occurs if the on size error phrase is used when this item is the receiving operand of an arithmetic
statement.

comp Data

If comp (or computational) is specified in the usage clause, the compiler chooses either comp-4, comp-5, or comp-6/binary, depending on the requirements implied by the picture. This selection determines the limits at which the on size error phrase is executed, as described above. The picture clause is required for comp data.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.