Why comp variable in cobol




















COMP-3 enables the computer to store two digits in each storage position, except for the rightmost position, which holds the sign. The sign is stored separately as the rightmost half-a-byte regardless of whether S is specified in the PIC or not. Data item is stored in packed decimal format. Each digit occupies half a byte 1 nibble and the sign is stored at the rightmost nibble.

The hexadecimal number C or F denotes a positive sign and the hexadecimal number D denotes a negative sign. Suppose if you move into a field defined 9 7. If you will use Usage Display data items for computation then the additional overhead is required to convert the data item to the proper type both before and after the computation. While using COMP-3 for computation then use 15 or fewer digits in PIC clause to avoid the use of library routines for multiplication and division. Using a signed data item with an odd number of digits produces more efficient code since this uses an integral multiple of bytes in storage for the data item.

The operational sign is contained in the leftmost bit. The above example, writing the record from the working-storage record and see how it is displayed during the file browse. So there should be change in the output when we displayed from file. Hex-on output always refers two layers. The data displays in each byte are a combination of both layers. COMP-1 usage clause is applicable to single floating point data type. COMP-1 is specified for internal floating point items which is single precision.

COMP-1 items are 4 bytes long. COMP-1 allows Signed floating point item where the sign will store on leftmost byte first bit which is allocated to exponent. In the 4 bytes, leftmost 8 bits to store exponent and remaining 24 bits stores mantissa. The COMP-1 memory calculations like below. COMP-1 will store the data in the format of mantissa and exponent.

COMPIn this case the data is represented in the decimal form, but one digit takes half a byte. The sign is stored separately as the rightmost half a byte character. For example S9 06 : which takes 4 bytes.



0コメント

  • 1000 / 1000