Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
karthik1680
Warnings : 2

New User

Joined: 14 May 2005
Posts: 64
Location: chennai

 Posted: Wed Dec 07, 2005 7:57 am    Post subject: What happens when we move comp-1 value to comp-3 hi, what happens when we move comp-1 value to comp-3?

khamarutheen

Active Member

Joined: 23 Aug 2005
Posts: 680
Location: NJ

 Posted: Wed Dec 07, 2005 10:58 am    Post subject: COMP hi frnd, Refer this link for more thing about COMP Fields http://www.discinterchange.com/reading_COBOL_layouts_.html
karthik1680
Warnings : 2

New User

Joined: 14 May 2005
Posts: 64
Location: chennai

 Posted: Wed Dec 07, 2005 11:44 am    Post subject: Re: regarding comp-1 THANKS FOR YOUR REPLY. BUT I ASKED WHAT HAPPENS WHEN WE MOVE COMP-1 VALUE TO COMP-3?
iknow

Active User

Joined: 22 Aug 2005
Posts: 413

Posted: Thu Dec 08, 2005 9:36 am    Post subject: Re: rearding comp-1

Hi karthik1680,

example

 Quote: 01 A PIC 9(4) COMP value 1000. 01 B PIC 9(4) COMP-3 value 3000.

Now, inside the procedure division say move A to B.
The result of B(comp-3) variable will be 1000+

NOTE

I tested using MS COBOL 85.

Let me know in case of any concerns.
iknow

Active User

Joined: 22 Aug 2005
Posts: 413

 Posted: Thu Dec 08, 2005 9:49 am    Post subject: Re: rearding comp-1 Hi There, As a follow up to my previous post I would to like add some more points about comp and comp3. Like comp-3 will add '+' in the LSB and store the rest of the bits. Say for eg: 01 A pic 9(5) value 10001 comp. 01 B pic 9(4) value 3000 comp3. Now if we use Move A to B. The result of B will be 0001+. As you can see '+' is placed in place of '1' in the LSB of B after moving value of A to B. Hope now you understand the actual usage of comp and comp3. NOTE Make use of our forums for various forms of COMP and COMP-3.
karthik1680
Warnings : 2

New User

Joined: 14 May 2005
Posts: 64
Location: chennai

 Posted: Fri Dec 09, 2005 7:00 am    Post subject: Re: What happens when we move comp-1 value to comp-3 hi iknow, thanks for your reply.but what happens in vs-cobol . this is a interview question
iknow

Active User

Joined: 22 Aug 2005
Posts: 413

 Posted: Fri Dec 09, 2005 7:13 am    Post subject: Re: What happens when we move comp-1 value to comp-3 Hi karthik1680, You raised an excellent quetion. I need to check on this one. I will let you know the exact solution.
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Sat Dec 10, 2005 6:01 am    Post subject: Hi Iknow, The ques is about COMP-1 not COMP.
iknow

Active User

Joined: 22 Aug 2005
Posts: 413

 Posted: Sat Dec 10, 2005 11:45 am    Post subject: Re: What happens when we move comp-1 value to comp-3 Hi mmwife, Sorry for the inconvenience. Let me give the exact solution on this. Thanks for correcting me.
karthik1680
Warnings : 2

New User

Joined: 14 May 2005
Posts: 64
Location: chennai

 Posted: Tue Dec 13, 2005 6:48 pm    Post subject: Re: What happens when we move comp-1 value to comp-3 hi iknow waiting for your reply
DavidatK

Active Member

Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

 Posted: Tue Dec 13, 2005 11:58 pm    Post subject: Re: What happens when we move comp-1 value to comp-3 COMP-1 is a floating point field, that requires no picture. In the following examples, please pay careful attention to how positive and negative numbers are handled. Particularly, pay attention to how fractional numbers are stored and rounded when moved to the COMP-3 field in examples 6 and 7. Then look at example 8 and how it moves to a COMP-3 field with sufficient precision to show the inaccuracies of floating point numbers. The floating point number is displayed as ?-.21474000E 05? The letters at the end of the other numbers represent the number + sign. If you look at these in hex, you will understand. If this doesn?t answer your questions. Come back again. WORKING-STORAGE SECTION. 01 WS. 05 WS-COMP-1 COMP-1. 05 WS-COMP-3 PIC S9(7) COMP-3. 05 WS-COMP-3A PIC S9(9) COMP-3. 05 WS-COMP-3B PIC S9(9)V9(6) COMP-3. Example 1: MOVE -12345 TO WS-COMP-3. DISPLAY WS-COMP-3. Results: 001234N Example 2: MOVE -21474 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. MOVE WS-COMP-3 TO WS-COMP-3A. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' ' WS-COMP-3A. Results: -.21474000E 05 002147M 00002147M Example 3: MOVE -1 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' '. Results: -.10000000E 01 000000J Example 4: MOVE 21474 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' '. Results: .21474000E 05 0021474 Example 5: MOVE 1 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' '. Results: .10000000E 01 0000001 Example 6: MOVE 27.563 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' '. Results: .27563004E 02 0000028 Example 7: MOVE 27.499 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3. DISPLAY WS-COMP-1 ' ' WS-COMP-3 ' '. Results: .27498993E 02 0000027 Example 8: MOVE 27.499 TO WS-COMP-1. MOVE WS-COMP-1 TO WS-COMP-3B. DISPLAY WS-COMP-1 ' ' WS-COMP-3B ' '. Results: .27498993E 02 000000027498993
iknow

Active User

Joined: 22 Aug 2005
Posts: 413