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

Data Representation in COBOL


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

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Sat Jan 07, 2006 7:01 pm
Reply with quote

Hi All,

Here is a sample code...

A PIC X(04) VALUE IS 'KLMN'.
B REDEFINES A PIC S9(04).
ADD 1000 TO B.
DISPLAY B.

This gives 134E as answer.

Could anyone please let me know how the data is actually stored and how this operation is actually performed.

Thanks and Regards,
Raveendra.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jan 10, 2006 3:59 am
Reply with quote

raveendra_ibm,

I just answered, I hope, this question for another member. Check this topic. if it doesn't answer your question please come back

www.ibmmainframes.com/viewtopic.php?t=7951&start=0&postdays=0&postorder=asc&highlight=

Luck,

Dave
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Tue Jan 10, 2006 9:10 am
Reply with quote

Hi Raveendra,

Since you're trying to move an Alphanumeric value to a numeric field, the compiler rules dictate that the sending field be numeric and unsigned.

For example


Quote:
WORKING-STORAGE SECTION.
01 A PIC X(04).
01 B PIC 9(04).
PROCEDURE DIVISION.
MOVE 'ABCD' TO A
MOVE A TO B
DISPLAY 'VALUE OF B IS : ' B
STOP RUN.


In the above example since you're trying to move X'C1C2C3C4' (an A/N value) to a numeric field, the compiler rules dictate that the sending field be numeric and unsigned.

It looks like it doesn't care about the non-sign digits (GIGO), but forces the 4 high order sign bits of the low order digit to X'F', overlaying the X'C' that's there. Since the low order bits of that digit is X"4" the full byte is X'F4' or a DISPLAY "4".


Hope this helps.


Please let me know if I am wrong.
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 Store the data for fixed length COBOL Programming 1
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top