IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What COBOL does with sign nibble in unsigned COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Nov 12, 2007 1:33 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Nov 12, 2007 3:41 pm
Reply with quote

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
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Nov 12, 2007 4:51 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Nov 12, 2007 5:02 pm
Reply with quote

Abin,
Please note the result variable is unsigned here so it is doing what you asked for.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top