Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
COMP, COMP1, COMP2 & COMP3 in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
raghu_4412
Warnings : 1

New User


Joined: 01 Mar 2004
Posts: 4
Location: Bangalore

PostPosted: Sat Mar 06, 2004 8:17 am    Post subject: COMP, COMP1, COMP2 & COMP3 in COBOL
Reply with quote

hello sir,

please explain me about COMP, COMP1, COMP2 & COMP3 with an example? how is memory allocated in each of the above?

what is meant by halfword & fullword binary in COMP & how the memory allocates?


please clear me doubt about the above mentiones questions.
Back to top
View user's profile Send private message
References
PostPosted: Sat Mar 06, 2004 8:17 am    Post subject: Re: COMP, COMP1, COMP2 & COMP3 in COBOL Reply with quote

sanga_1978

New User


Joined: 07 Mar 2004
Posts: 1

PostPosted: Sun Mar 07, 2004 8:35 pm    Post subject: details about comp
Reply with quote

hai,


the following is the details of COMP items.


BINARY
Specified for binary data items. Such items have a decimal equivalent
consisting of the decimal digits 0 through 9, plus a sign. Negative
numbers are represented as the two's complement of the positive number
with the same absolute value.

The amount of storage occupied by a binary item depends on the number
of decimal digits defined in its PICTURE clause:

Digits in PICTURE Clause Storage Occupied
1 through 4 2 bytes (halfword)
5 through 9 4 bytes (fullword)
10 through 18 8 bytes (doubleword) │
The leftmost bit of the storage area is the operational sign.

PACKED-DECIMAL
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 low-order 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.

The sign representation uses the same bit configuration as the 4-bit
sign representation in zoned decimal fields (see Table 12 in
topic 2.7.12.2 and Table 13 in topic 2.7.12.2).

COMPUTATIONAL or COMP
Representation of the COMPUTATIONAL phrase is system-dependent and is
normally assigned to representations that yield the greatest
efficiency when arithmetic operations are performed on that system.
For the VS COBOL II compiler, the COMPUTATIONAL phrase is synonymous
with BINARY.

COMPUTATIONAL-1 or COMP-1
Specified for internal floating-point items (single precision).
COMP-1 items are 4 bytes long. The sign is contained in the first bit
of the leftmost byte and the exponent is contained in the remaining 7
bits. The last 3 bytes contain the mantissa.

COMPUTATIONAL-2 or COMP-2
Specified for internal floating-point items (double precision).
COMP-2 items are 8 bytes long. The sign is contained in the first bit
of the leftmost byte and the remaining 7 bits contain the exponent.
The remaining 7 bytes contain the mantissa.

COMPUTATIONAL-3 or COMP-3 (internal decimal)
For VS COBOL II, this is the equivalent of PACKED-DECIMAL.

COMPUTATIONAL-4 or COMP-4 (binary)
For VS COBOL II this is the equivalent of BINARY.

by
g.s.sanker
Back to top
View user's profile Send private message
thalapradheep

New User


Joined: 05 Dec 2007
Posts: 4
Location: India

PostPosted: Mon Jan 28, 2008 5:01 pm    Post subject: need help?
Reply with quote

How much bytes will S9(18) Comp will occupy?
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 120
Location: At my Desk

PostPosted: Mon Jan 28, 2008 5:08 pm    Post subject: Reply to: COMP, COMP1, COMP2 & COMP3 in COBOL
Reply with quote

How much bytes will S9(18) Comp will occupy?


8 bytes
Back to top
View user's profile Send private message
stodolas

Senior Member


Joined: 13 Jun 2007
Posts: 597
Location: Wisconsin

PostPosted: Mon Jan 28, 2008 6:24 pm    Post subject:
Reply with quote

Really? 8 bytes? It uses less than 1/2 of its size? That doesn't seem quite logical to me... Does it seem correct to you? Which platform is that on? From what I read the size of COMP is compiler vendor specific.
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 6033
Location: 221 B Baker St

PostPosted: Mon Jan 28, 2008 10:14 pm    Post subject:
Reply with quote

Hello,

With Enterprise COBOL, these:

Code:
 77  SMLBINARY           PIC S9(2)  COMP  VALUE 10.   
 77  MEDBINARY           PIC S9(9)  COMP  VALUE 100.   
 77  BIGBINARY           PIC S9(18) COMP  VALUE 100.   
result in these lengths:
Code:
 BLW=00000+018         2C
 BLW=00000+020         4C
 BLW=00000+028         8C
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1