| Author |
Message |
raghu_4412 Warnings : 1 New User
Joined: 01 Mar 2004 Posts: 4 Location: Bangalore
|
|
|
|
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 |
|
 |
References
|
Posted: Sat Mar 06, 2004 8:17 am Post subject: Re: COMP, COMP1, COMP2 & COMP3 in COBOL |
 |
|
|
 |
sanga_1978
New User
Joined: 07 Mar 2004 Posts: 1
|
|
|
|
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 |
|
 |
thalapradheep
New User
Joined: 05 Dec 2007 Posts: 4 Location: India
|
|
|
|
| How much bytes will S9(18) Comp will occupy? |
|
| Back to top |
|
 |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 120 Location: At my Desk
|
|
|
|
How much bytes will S9(18) Comp will occupy?
8 bytes |
|
| Back to top |
|
 |
stodolas
Senior Member
Joined: 13 Jun 2007 Posts: 597 Location: Wisconsin
|
|
|
|
| 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 |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 6033 Location: 221 B Baker St
|
|
|
|
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 |
|
 |
|
|