Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Advantages of COMP over COMP-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Sharan

New User


Joined: 22 Dec 2003
Posts: 6
Location: Banaglore

PostPosted: Mon Dec 22, 2003 9:19 pm    Post subject: Advantages of COMP over COMP-3
Reply with quote

Hi,

I understand that COMP-3 data occupies lesser space than a COMP variable. Assuming it this way why is that people prefer COMP over COMP-3. Is there any specific reasons that the COMP data have over COMP-3 variables. It would be great if some of you can give me an answer to the same.
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Dec 23, 2003 4:51 am    Post subject:
Reply with quote

Hi Sharan,

There are various flavors of COMP, e.g. COMP-4/5, and compiler options that change it's execution characteristics. Check your compiler' manual for details.

Whoever told you that COMP-3 uses less storage than COMP was technically correct, but misleading. For numbers 0 thru 9 it's correct: COMP-3 requires 1 byte, COMP requires 2. However, a 2 byte signed COMP field can house numbers to +/-61439, while 2 bytes of COMP-3 can accommodate numbers limited to +/-999.

Another reason for choosing COMP is that it uses register to register arithmetic; a faster method than decimal arithmetic.

Regards, Jack.
Back to top
View user's profile Send private message
prasanth_thavva

New User


Joined: 28 Jul 2005
Posts: 86
Location: Chennai

PostPosted: Thu Sep 08, 2005 10:49 am    Post subject:
Reply with quote

For numbers
Quote:
0 thru 9 it's correct
: COMP-3 requires 1 byte, COMP requires 2. However, a 2 byte signed COMP field can house numbers to +/-61439, while 2 bytes of COMP-3 can accommodate numbers limited to +/-999.

Quote:
can u explain me breifly ?

bye

how can a comp-3 occupies
0-9 comp-3 occupies 1 byte for signed it can house -/+999
Back to top
View user's profile Send private message
amalli

New User


Joined: 06 Sep 2005
Posts: 17

PostPosted: Thu Sep 08, 2005 12:18 pm    Post subject: Which is Fastest of comp or comp3?
Reply with quote

Comp3 is Packed decimal Format
Comp i Binary Format.


Which is Fastest of comp or comp3?
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Fri Sep 09, 2005 1:35 am    Post subject:
Reply with quote

mmwife,
Quote:
However, a 2 byte signed COMP field can house numbers to +/-61439

If I understood u correctly, according to my calculations I can accomodate +/- 9999 for COMP items and +32767 to -32768 for COMP-5. COMP-3 showed +/-999 as u have said. Let me know If I am missing something.
Back to top
View user's profile Send private message
nitin_agr

New User


Joined: 06 Sep 2005
Posts: 28
Location: Minneapolis US

PostPosted: Fri Sep 09, 2005 2:07 am    Post subject:
Reply with quote

Hi Friends;

Here I want to contribute a few lines in this discussion, those might helpful to understand it very clearly.

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:
1 through 4 2 bytes (halfword)
5 through 9 4 bytes (fullword)
10 through 18 8 bytes (doubleword)

The operational sign for ?big-endian? binary data (such as OS/390 and VM) is contained in the left most bit of the binary data. The operational sign for ?little-endian? binary data is contained in the left most bit of the right most byte of the binary data.

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.

Following is the range I found in a IBM COBOL Programming manual

Picture Storage representation Numeric values

S9(1) through S9(4) Binary half-word (2 bytes) -32768 through +32767
S9(5) through S9(9) Binary full-word (4 bytes) -2,147,483,648 through
+2,147,483,647
S9(10) through S9(18) Binary double-word (8bytes) -9,223,372,036,854,775,808 through +9.223,372,036,854,775,807

9(1) through 9(4) Binary half-word (2 bytes) 0 through 65535
9(5) through 9(9) Binary full-word (4 bytes) 0 through 4,294,967,295
9(10) through 9(18) Binary double-word (8bytes) 0 through 18,446,744,073,709,551,615
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 10, 2005 9:51 pm    Post subject:
Reply with quote

Nadal,
Quote:
+32767 to -32768 for COMP-5.

You're correct. Don't know what I did there.


Quote:
COMP-3 showed +/-999 as u have said.

Using TRUNC(BIN) as a compiler option will allow data values of +32767 to -32768 as above regardless of the PIC 9s.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us