VOOZH about

URL: https://www.geeksforgeeks.org/cobol/comp-1-in-cobol/

⇱ COMP-1 in COBOL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

COMP-1 in COBOL

Last Updated : 8 Aug, 2022

In COMP Usage data will get stored in the complete binary form. Based on the usage the data will get stored either in HALF-WORD or FULL-WORD. HALF-WORD which is nothing but 2-bytes data having the range of -32,768 to +32,767 and FULL-WORD is nothing but 4-bytes of data with-in the range of -2,147,483,648 to +2,147,483,648.

When it comes to COMP-1 , so in COMP-1 data will get stored in one-word in the floating point form. Actually it will represent in the hexadecimal form, which is suitable for all types of arithmetic operation.

We need not specifically use the PICTURE Clause for COMP-1 variables, Because PIC will helps to create relation between data name and data type but in COMP-1 date is numeric and the data type is already pre-defined as one word floating form. 

Example:

Output:

👁 Image
 

Explanation:

In this example, we are displaying the comparison example for COMP and COMP-1. So we can see that the length of the COMP variables are varying based on the input data but for the COMP-1 variable length is 4 bytes and also we are not specifying the PICTURE Clause.

Comment
Article Tags: