I want to share some awesome COBOL data types, which look so complex to many COBOL developers.
Let us come to the point…
What is comp-1
Comp-1 is also called a single-precision floating-point number. PIC is not required.
Single-precision floating-point format is a computer number format that occupies 4 bytes (32 bits) in computer memory and represents a wide dynamic range of values by using a floating-point.
Comp-1 items are 4 bytes long. Internally data is stored in hexadecimal format
01 floattmp USAGE COMP-1;
In IEEE 754-2008 the 32-bit base 2 format is officially referred to as binary32. It was called single in IEEE 754-1985. In older computers, other floating-point formats of 4 bytes were used.
Free COBOL Tutorial Download Now
What is comp-2
Comp-2 is also called double-precision floating-point number. PIC is not required.
Double-precision floating-point format is a computer number format that occupies 8 bytes (64 bits) in computer memory and represents a wide dynamic range of values by using floating-point.
So comp-2 items are 8 bytes long. Internally data is stored in hexadecimal format.
01 floattmp2 USAGE COMP-2;
- Computers with 32-bit storage locations use two memory locations to store a 64-bit double-precision number (a single storage location can hold a single-precision number).
- Double-precision floating-point format usually refers to binary64, as specified by the IEEE 754 standard, not to the 64-bit decimal format decimal64.