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
 
What happens when we move comp-1 value to comp-3

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

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Wed Dec 07, 2005 7:57 am    Post subject: What happens when we move comp-1 value to comp-3
Reply with quote

hi,

what happens when we move comp-1 value to comp-3?
Back to top
View user's profile Send private message

khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Dec 07, 2005 10:58 am    Post subject: COMP
Reply with quote

hi frnd,
Refer this link for more thing about COMP Fields

http://www.discinterchange.com/reading_COBOL_layouts_.html
Back to top
View user's profile Send private message
karthik1680
Warnings : 2

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Wed Dec 07, 2005 11:44 am    Post subject: Re: regarding comp-1
Reply with quote

THANKS FOR YOUR REPLY.
BUT I ASKED WHAT HAPPENS WHEN WE MOVE COMP-1 VALUE TO COMP-3?
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Thu Dec 08, 2005 9:36 am    Post subject: Re: rearding comp-1
Reply with quote

Hi karthik1680,

Here is the answer for your query.

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.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Thu Dec 08, 2005 9:49 am    Post subject: Re: rearding comp-1
Reply with quote

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.
Back to top
View user's profile Send private message
karthik1680
Warnings : 2

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Fri Dec 09, 2005 7:00 am    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

hi iknow,
thanks for your reply.but what happens in vs-cobol . this is a interview question
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Fri Dec 09, 2005 7:13 am    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

Hi karthik1680,

You raised an excellent quetion. I need to check on this one.

I will let you know the exact solution.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 10, 2005 6:01 am    Post subject:
Reply with quote

Hi Iknow,

The ques is about COMP-1 not COMP.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Sat Dec 10, 2005 11:45 am    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

Hi mmwife,

Sorry for the inconvenience. Let me give the exact solution on this.


Thanks for correcting me.
Back to top
View user's profile Send private message
karthik1680
Warnings : 2

New User


Joined: 14 May 2005
Posts: 64
Location: chennai

PostPosted: Tue Dec 13, 2005 6:48 pm    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

hi iknow
waiting for your reply
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Tue Dec 13, 2005 11:58 pm    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

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
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Wed Dec 14, 2005 6:21 am    Post subject: Re: What happens when we move comp-1 value to comp-3
Reply with quote

Hi Davidatk,

Thanks for your reply.

I tried using MS-COBOL85 but the problem is COMP-1 is not recognized by MS-COBOL85.
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 Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm

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