View previous topic :: View next topic
|
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 |
|
|
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: 218 Location: India
|
|
|
|
How much bytes will S9(18) Comp will occupy?
8 bytes |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 631 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Shanmugavel
New User
Joined: 15 Dec 2006 Posts: 7 Location: CHENNAI
|
|
|
|
dick scherrer,
I didn't understand the above piece of code and BLW is.
Can you explain it some more? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
The 77-level variables "code" is to show 3 binary numbers of different length.
The "result" is what the compiler assigned for these variables and is generated in the listing from the compile.
There are no executable instructions. These were only to demonstrate the length of these data items. |
|
Back to top |
|
|
sid_aec
New User
Joined: 01 Jul 2008 Posts: 60 Location: Kolkata
|
|
|
|
Hi ,
I think what senario Dick actually wanted to explain is as below:
PIC S9(01) COMP -> PIC S9(04) COMP :Takes 2 bytes.
PIC S9(05) COMP -> PIC S9(09) COMP :Takes 4 bytes.
PIC S9(10) COMP or above :Takes 8 bytes. |
|
Back to top |
|
|
manishmittal
New User
Joined: 25 Apr 2008 Posts: 49 Location: Gurgaon
|
|
|
|
Hi all,
My apologies for replying to an year old post.But i just want to confirm if the above answer is correct.
Thanks. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
manishmittal wrote: |
My apologies for replying to an year old post.But i just want to confirm if the above answer is correct. |
well you could either mimic Dick's experiment, or you could check the COBOL Prg Guide and insure that sanga_1978 paraphrased everything properly. |
|
Back to top |
|
|
manishmittal
New User
Joined: 25 Apr 2008 Posts: 49 Location: Gurgaon
|
|
|
|
I tried it by defining some binary variables with different lenghts in a copubook and then opening this copybook against a dummy input file usinf Fileaid.But the results i got are conflicting with this post. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
manishmittal wrote: |
I tried it by defining some binary variables with different lenghts in a copubook and then opening this copybook against a dummy input file usinf Fileaid.But the results i got are conflicting with this post. |
what different lenghts did you use? elementary items defined as USAGE Binary are 2,4,8 bytes long, depending upon the pic clause.
what are the conflicting results? |
|
Back to top |
|
|
manishmittal
New User
Joined: 25 Apr 2008 Posts: 49 Location: Gurgaon
|
|
|
|
Please accept my apologies.After going thru the Program Reference guide and changing the copybook according to that i found the same results as mentioned in the post..
Thanks for the clarification. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Manish,
apologies are not needed.
That you have learned something is of paramount importance;
that was the reason for my remarks.
good luck! |
|
Back to top |
|
|
|