Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How are Alphanumeric variables(character) stored?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How are Alphanumeric variables(character) stored?
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: 3158
Location: Tucson AZ

PostPosted: Mon Apr 30, 2007 1:05 am    Post subject:
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

Site Director


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

PostPosted: Mon Apr 30, 2007 1:16 am    Post subject:
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    Post subject: Re: How are Alphanumeric variables(character) stored?
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

Site Director


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

PostPosted: Mon Apr 30, 2007 10:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us