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

How are Alphanumeric variables(character) stored?


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

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Sun Apr 29, 2007 11:39 pm
Reply with quote

Hello,

I came across a document which says that a character(alphanumeric) variable is stored in one byte per one digit.

Can you please tell me how the value 'ABC' is stored?

A document says +1234 in character format is stored as follows:
The most significant bit is on the left:

Mode Byte 4 Byte 3 Byte 2 Byte 1
========= ======== ======== ======== ========

Character 00110001 00110010 00110011 00110100

what do the ones in bold signify?
Can you please explain how a 2 byte storage can store a maximum value of 99 for a character variable?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Apr 30, 2007 1:05 am
Reply with quote

Yes, one byte per digit or character.
In hex, X'C1C2C3'.
Depending on the format, I'd tend to agree, ZD the most significant byte, PD the most significant half byte, binary the sing bit then the most significant bit.0011 is a binary 3, the binary string is X'31313334' which I would take as ASCII 1234.
Two bytes of storage can contain 00 thru 99 when usage is ZD, 0 thru 999 when usage is PD, 0 thru 32767 when usage is binary (plus 1 if you ignore the sign).
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Apr 30, 2007 1:16 am
Reply with quote

Hello,
Quote:

A document says +1234 in character format is stored as follows:
The most significant bit is on the left:

Code:
Mode Byte 4 Byte 3 Byte 2 Byte 1
========= ======== ======== ======== ========

Character 00110001 00110010 00110011 00110100


My recommendation would be to find a different document (at least as far as providing info for an IBM mainframe is concerned). The above is not for the IBM mainframe (EBCDIC character set), but rather how things are stored on UNIX and Win-based systems (ASCII). Care must be taken to make sure the document and the platform are the "same".

For your first question 'ABC' is stored as x'C1C2C3' which in binary is
'1100 0001 1100 0010 1100 0011' (on the mainframe). One byte of alphanumeric data is 2 hexadecimal digits (0-F) or 8 binary digits (0-1). Every 1-byte value is between x'00' and x'FF'.

Back to the info from the document. . .

Let's start with the PICture. For this
Quote:
+1234 in character format
the PICture in a COBOL program would be PIC S9(4). Internally, it would be stored as x'F1F2F3C4' - note the "C" sign in the low order digit.
The binary value is 1111 0001 1111 0010 1111 0011 1100 0100'

Keep in mind that both the EBCDIC and ASCII character sets are represented by x'00-FF', but the values for the bit patterns is not the same between platforms. This also leads to a difference in collating sequence - the biggest/easiest example is that the numbers 0-9 are lower in the collating sequence than A-Z on ASCII systems, but 0-9 is higher than A-Z on the mainframe.

There are multiple places on the web where you might download both character sets.
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Mon Apr 30, 2007 10:01 pm
Reply with quote

I was a bit confused when I saw the ASCII characters being shown in the document. Now, I am clear. Thanks a lot for your help.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Apr 30, 2007 10:05 pm
Reply with quote

You're welcome icon_smile.gif
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 Panvalet - 9 Character name - Issue c... CA Products 6
No new posts JCL with variables JCL & VSAM 1
No new posts Invoke stored procedure via batch JCL. DB2 2
No new posts String has hex character need to conv... COBOL Programming 3
No new posts Output LREC based on specific character DFSORT/ICETOOL 22
Search our Forums:

Back to Top