View previous topic :: View next topic
|
Author |
Message |
himanshu7
Active User
Joined: 28 Aug 2007 Posts: 131 Location: At Desk
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
himanshu7
Active User
Joined: 28 Aug 2007 Posts: 131 Location: At Desk
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
himanshu7
Active User
Joined: 28 Aug 2007 Posts: 131 Location: At Desk
|
|
|
|
Thanks for the reply.
Instead of asking i would have gone through the manual.
Thanks Again.. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Quote: |
...no reason for us to repeat the manual and allow you to waste a learning opportunity. |
Nicely put. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Thank you Terry! |
|
Back to top |
|
|
|