Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Doubt In COMP-3 and Binary Values

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

Active User


Joined: 28 Aug 2007
Posts: 131
Location: At Desk

PostPosted: Fri Nov 06, 2009 4:29 pm    Post subject: Doubt In COMP-3 and Binary Values
Reply with quote

Hi this is the program im using to display the value in diff usage clause.

Code:
01 TVR-DATA.                                                 
    03  DECIMAL-DATA            PIC 9(03) VALUE ZEROS.       
    03  BINARY-DATA             PIC S9(04) BINARY             
                                    VALUE ZEROS.             
    03  PACKD-DEC-DATA          PIC S9(03) COMP-3 VALUE ZEROS.
PROCEDURE DIVISION.                                           
                                                             
    MOVE 157         TO BINARY-DATA.                         
    MOVE BINARY-DATA TO DECIMAL-DATA, PACKD-DEC-DATA.         
    DISPLAY 'BINARY-DATA:' BINARY-DATA.                       
    DISPLAY 'DECIMAL-DATA' DECIMAL-DATA.                     
    DISPLAY 'PACKD-DEC-DATA' PACKD-DEC-DATA.                 
    STOP RUN.                               


The output
Code:

*********************
BINARY-DATA:0157     
DECIMAL-DATA157     
PACKD-DEC-DATA157   
*********************


Question are:

1:Is it possible to move values to diff usage clause?
2.How come it is displaying the COMP-3 values?
3.How are the values stored internally in comp-3 and binary as it is displaying the decimal values?


Thank you
Back to top
View user's profile Send private message

Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Nov 06, 2009 5:11 pm    Post subject:
Reply with quote

Hi Himanshu,

If my understanding is correct, you have asked some pretty basic stuff only. Am sure some effort spent with the manuals will help you...
Back to top
View user's profile Send private message
himanshu7

Active User


Joined: 28 Aug 2007
Posts: 131
Location: At Desk

PostPosted: Fri Nov 06, 2009 5:22 pm    Post subject:
Reply with quote

Hi Binop,

As per my understanding I thought we can never display the hexa decimal value.Howevere in the above we can certainly see the COMP-3 variables.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Nov 06, 2009 5:56 pm    Post subject:
Reply with quote

Quote:
As per my understanding I thought


that was your first error, not checking to insure that your understanding was correct.

and checking normally means looking at the manual.

and while you are checking, learn the meaining of hexadecimal. IBM mainframes are ebcidc.

and What was the intent of your question about the results of your test? for us to help you find a bug in COBOL?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Fri Nov 06, 2009 6:10 pm    Post subject:
Reply with quote

Answers are:
1. Obviously, since you did it, the answer is yes.
2. Study the COBOL Language Reference manual (manuals link at the top of the page) -- and you will find DISPLAY will display numeric data as numbers no matter what the USAGE clause is
3. The manual will tell you what format internally is used for storage; no reason for us to repeat the manual and allow you to waste a learning opportunity.
Back to top
View user's profile Send private message
himanshu7

Active User


Joined: 28 Aug 2007
Posts: 131
Location: At Desk

PostPosted: Fri Nov 06, 2009 7:20 pm    Post subject:
Reply with quote

Thanks for the reply.
Instead of asking i would have gone through the manual.

Thanks Again..
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Nov 07, 2009 4:27 am    Post subject:
Reply with quote

Quote:
...no reason for us to repeat the manual and allow you to waste a learning opportunity.

Nicely put. icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Sat Nov 07, 2009 4:40 am    Post subject:
Reply with quote

Thank you Terry! icon_smile.gif
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 BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us