Summary -

In this topic, we described about the Comp-1/Computation-1 with detailed example.

Specifies for internal floating-point items that are single precision. COMP-1 items are 4 bytes long.

COMP-1 items can't have PICTURE clause. COMP-1 allows VALUE clause with floating-point literal.

COMP-1 allows signed floating-point item where the sign stores on leftmost bit. COMP-1 stores the data in the format of mantissa and exponent.

In this, mantissa is numeric value and exponent is the precision number. In the 4 bytes, leftmost first bit to store sign, next 7 bits to store exponent and remaining 24 bits stores mantissa.

Below table represents the storage occupation based on the number of digits in PICTURE clause –

Digits in PICTURE clause Storage occupied
1 through 16 4 bytes (full word)

For example, 9.999 value required to store in data item which is declared as COMP-1. The data stores in the memory like 9999 * 10-3.

9.999 equal to 9999 * 10-3. In the above, -3 is exponent value (stored in left most 8 bits) and 9999 is mantissa (stored in remaining 24 bits).

Practicle Example -

Code -


 IDENTIFICATION DIVISION.                                         
 PROGRAM-ID. COMP1.                                               
 ENVIRONMENT DIVISION.                                            
 DATA DIVISION.                                                   
 WORKING-STORAGE SECTION.                                         
 01 COMP1-NM              PIC 9(03) USAGE COMP-1 VALUE '256'.     
 PROCEDURE DIVISION.                                              
     DISPLAY 'COMPUTATION-1..'.                                   
     DISPLAY 'COMPUTATION1 - NUMERIC [9(01) - 9(16)]-> 4 BYTES '. 
     DISPLAY COMP1-NM.                                            
     STOP RUN.