View previous topic :: View next topic
|
Author |
Message |
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi,
I have a field with following declaration.
Code: |
REC-CNTRL-NO PIC 9(11) COMP-3. |
In input following are the values for two records in this field.
Code: |
011111
111110
-------
111111
22222B |
My code is as follows.
Code: |
COMPUTE REC-CNTRL-NO = REC-CNTRL-NO * 1 |
Out put I got is
Code: |
011111
11111F
-------
111111
22222F |
It looks like for Unsigned comp-3 the sign nibble is of no importance. But it fails in numeric test.
Could some one please explain what COBOL does with sign nibble in unsigned COMP-3. I know that for unsigned COMP-3 valid value is only 'F'.
Also when I move this field into a signed COMP-3 field I am getting a C in the sugn nibble, regardless of the value in input sign nibble. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
It is just COBOL doing what you asked it to do by specifing unsigned, COBOL in insuring all operations on the field see a generic positive by ORing the F into the sign nibble..... |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi ,
COBOL is cool in this matter even with a code as below it is ORing F with the sign nibble, regardless of the value in input sign nibble.
Code: |
COMPUTE REC-CNTRL-NO = REC-CNTRL-NO
* -1 |
|
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Abin,
Please note the result variable is unsigned here so it is doing what you asked for. |
|
Back to top |
|
|
|