View previous topic :: :: View next topic

Author 
Message 
sihanature Warnings : 1 New User
Joined: 01 Sep 2005 Posts: 33




Hi All,
Can anyone describe the exact use of Comp variable in Cobol program with some examples. 

Back to top 




nitin_agr
New User
Joined: 06 Sep 2005 Posts: 28 Location: Minneapolis US




Following may help you...
COMPUTATIONAL or COMP (binary)
This is the equivalent of BINARY. The COMPUTATIONAL phrase is
synonymous with BINARY.
COMPUTATIONAL1 or COMP1 (floatingpoint)
Specified for internal floatingpoint items (single precision). COMP1 items are 4 bytes long.
COMPUTATIONAL2 or COMP2 (long floatingpoint)
Specified for internal floatingpoint items (double precision). COMP2 items
are 8 bytes long.
COMPUTATIONAL3 or COMP3 (internal decimal)
This is the equivalent of PACKEDDECIMAL.
COMPUTATIONAL4 or COMP4 (binary)
This is the equivalent of BINARY.
COMPUTATIONAL5 or COMP5 (native binary)
These data items are represented in storage as binary data. The data items cancontain values up to the capacity of the native binary representation (2, 4 or 8 bytes), rather than being limited to the value implied by the number of nines in the picture for the item (as is the case for USAGE BINARY data). When numeric data is moved or stored into a COMP5 item, truncation occurs at the binary field size, rather than at the COBOL picture size limit. When a COMP5 item is referenced, the full binary field size is used in the operation.
PACKEDDECIMAL
Specified for internal decimal items. Such an item appears in storage in
packed decimal format. There are 2 digits for each character position, except for the trailing character position, which is occupied by the loworder digit and the sign. Such an item can contain any of the digits 0 through 9, plus a sign, representing a value not exceeding 18 decimal digits.
For more details you can refer IBM COBOL Programming Guide. 

Back to top 



