IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Doubt In COMP-3 and Binary Values


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 6966
Location: porcelain throne

PostPosted: Fri Nov 06, 2009 5:56 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 06, 2009 6:10 pm
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Nov 07, 2009 4:40 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top