View previous topic :: View next topic
|
Author |
Message |
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi,
Can somebody explain this.
Here is my data definition
Code: |
01 WS-TEST.
05 WS-ALPHA PIC X(12)
VALUE '1234567 '.
05 WS-NUMERIC PIC 9(12).
|
Here is my code
Code: |
INITIALIZE WS-NUMERIC
DISPLAY WS-ALPHA
DISPLAY WS-NUMERIC
MOVE WS-ALPHA TO WS-NUMERIC
DISPLAY WS-NUMERIC
GOBACK
|
and here is what I get
Code: |
1234567
000000000000
1234567 0
|
Here is the question what is the 0 doing at end of my output 1234567 0 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
MVC 12(12,8),0(8)
OI 23(8),X'F0' |
I tested a similar program and here's the assembler generated. COBOL is forcing the last byte to have an unsigned value, which changes the space to a zero. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Robert,
Thanks for help. The code I used was ugly. This is how I fixed it.
Quote: |
COMPUTE WS-NUMERIC = FUNCTION NUMVAL(WS-ALPHA) |
I hope this is the best way. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Glad I could help. Your fix might or might not be the best way, but it'll work and is easy to maintain -- stick with it. |
|
Back to top |
|
|
|