View previous topic :: View next topic
|
Author |
Message |
PrabakarV
New User
Joined: 21 Dec 2007 Posts: 88 Location: My Desk
|
|
|
|
Var declaration:
Code: |
05 A PIC 9(02) COMP.
05 FILLER REDEFINES A.
10 FILLER PIC X.
10 B PIC X. |
Proc Division:
Code: |
ADD 1 TO A
MOVE B TO C |
In here initial value of A is zero before adding one. After that A had '01' in it. But i am not getting the second byte of A in B.
Please let me know if this is a wrong way of declaring. Please help me solve this issue. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Suggest you do a lot of reading in the cobol manuals about how numeric data items are stored!!! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
What did you get for the value of B?
What did you expect the value of B to be? |
|
Back to top |
|
|
PrabakarV
New User
Joined: 21 Dec 2007 Posts: 88 Location: My Desk
|
|
|
|
I want B to have value '1'. But i have low values in there which was moved at the start of program. I know this is wrong way of declaring but not 100% sure. I like to confirm my understanding. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
When you move zero to A, B will have LOW-VALUES. That is just the way COBOL works -- as Craq mentioned, you need to spend LOTS of time in the COBOL manuals understanding internal formats for data in COBOL. If you want B to have the value '1' (hex F1), you need to move 241 to A. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Do you want an x'F1' or an x'01' in B?
If you post what you Really Want, someone should be able to help.
As it is now, all we can recommend is to spend the time in the documentation. We really do not understand your goal. . . |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Robert Sample wrote: |
WIf you want B to have the value '1' (hex F1), you need to move 241 to A. |
I know you know Robert, but it does depend, with a PIC 99 COMP, on compile options whether 241 would actually fit into the field... may end up with 41 only, and max of 99. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
You are right, Bill -- and I should have said that. Thanks for catching it! |
|
Back to top |
|
|
jepson
New User
Joined: 24 Oct 2008 Posts: 7 Location: India
|
|
|
|
wouldn't B have the value of x'01' ? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
From what has been described, yes, X'01' would be the value of B. It is unclear if that is the "1" which is required but poorly-described, or if "1" as in X'F1' is what is expected.
We await TS's return on that. |
|
Back to top |
|
|
Jarek.B
New User
Joined: 21 Jun 2012 Posts: 2 Location: UK
|
|
|
|
PrabakarV wrote: |
I want B to have value '1'. But i have low values in there... |
You have a binary 1 in B but DISPLAY B won't display it what may confuse you. Still, you may see it on sysout if you switch your editor to hex mode.
If you want character 1 (hex code F1 in EBCDIC) then make A a character item: A PIC 9(2) without COMP.
Coded,tested,posted. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest PrabakarV look at the lengths and displacements generated by the compiler. . .
If this info is not clear to you, post it here and someone will be able to clarify.
It should help understand what is happening. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Try using TRUNC(BIN) compiler option. |
|
Back to top |
|
|
slade
New User
Joined: 24 Nov 2007 Posts: 1 Location: NJ
|
|
|
|
Hi,
If PrabakarV is still in the building, he might also supply us the PIC, etc. for "C". |
|
Back to top |
|
|
|