View previous topic :: View next topic
|
Author |
Message |
k_sanu4u
New User
Joined: 23 Mar 2007 Posts: 8 Location: india
|
|
|
|
01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3.
MOVE VAR-A TO VAR-B.
WHAT WILL BE THE VALUE OF VAR-B? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi k_sanu4u,
Why dont u try urself rather then asking? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Are you sure you will even be allowed to do that move? |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
You can't move char to a packed decimal..
It shouldn't even compile
~Vamsi |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
My guess is that you'll get X'00000F' which, of course, is packed unsigned zeros. Another possiblity is X'000004', but I think the "sign" gets ORed to an F. |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
this was the compilation error:
"' '" and "X-1 (PACKED INTEGER)" did not follow the "MOVE" statement compatibility rules. The statement was discarded. |
|
Back to top |
|
|
k_sanu4u
New User
Joined: 23 Mar 2007 Posts: 8 Location: india
|
|
|
|
i got zeros as answer while execueting ...can u justify ur answers... |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3. |
Explanation
Space = '40' H in EBCDIC
VAR-A = '4040404040'H
After move you will get '00000F' in VAR-B.
See the move worked this way. Only Lower nibbles were considered.
Compiler will generate code for this 'alignment'.
Similarly when there are all 'A's in VAR-A, you will get 11111 (A= C1 H)
When ALL 'B's then you will get 22222 (B= C2 H)
When ALL 'X's then you will get 77777 (X= E7 H)
It can be perceived as upper nibble of each byte is ignored in each move. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I'd only add this to Abhijit's excellent explanation:
The 1st step in the conversion produces X'000004' (the two low order nybbles (40) are reversed, not compressed as the others are). Then, because the PIC of VAR-B is unsigned, the low order byte X(04) is ORed to produce X'0F' making the VAR-B value X'00000F' |
|
Back to top |
|
|
|