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

Hexadecimal conversion


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

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Mon Dec 21, 2009 12:43 pm
Reply with quote

I have a input field PIC X(3) with hexadecimal values like X'256A40'.
The requirement is to have it noutput as PIC X(7) where the value will be 2452032. The input can be any hexadecimal value and this is just one example.

Please suggest the shortest possible code in cobol.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 21, 2009 2:22 pm
Reply with quote

what you are talking about is Binary to Decimal conversion.

now that you have the correct terms, you can research in the manuals (Application programmers guide).

By the way:
Pic x(03) can contain up to and including x'FFFFFF', which is decimal 16777215 or PIC x(08).

So if you want your display to be as inaccurate as your description, leave it at Pic x(07).
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Dec 21, 2009 2:25 pm
Reply with quote

What have you done so far? Have you tried searching forum. similar was discussed around month back.
Back to top
View user's profile Send private message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Mon Dec 21, 2009 2:38 pm
Reply with quote

Binary and hex are the same in this case? I mean the inputis defined as X(3), but binary is numeric right? I am sorry if I have asked something stupid.

But I would be very thankful if someone can give me the solution.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Dec 21, 2009 3:56 pm
Reply with quote

Binary is base two. Hex (hexadecimal) groups 4 binary digits together to create base 16 values, primarily to reduce the length of the data representations (sets of 32 1's and 0's -- or sets of 64 -- are hard to read, hard to interpret, and easy to get messed up).


Quote:
But I would be very thankful if someone can give me the solution.
This is a HELP forum, not a DO-YOUR-JOB-FOR-YOU forum. However, there are a number of people willing to provide you a solution should you pay them the appropriate fee.
Back to top
View user's profile Send private message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Mon Dec 21, 2009 3:59 pm
Reply with quote

didnt mean to offend anyone, just was trying to see if someone can direct me to the solution. I could not understand it yet
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Dec 21, 2009 5:07 pm
Reply with quote

Being that your name suggests interest in CICS, how could you convert EIBCALEN (two-bytes binary) to display-numeric, so that it can be viewed in readable format?

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 21, 2009 5:25 pm
Reply with quote

CICS fan,

one way, which has been repeatedly provided as a solution in other threads,
is to define a binary field so that it can be redefined with elementary elements of pic x(01) value low values and a pic x(03).
move your pic x(03) to the elementary element, move the Binary defined field to a display numeric.
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 Dec 21, 2009 8:24 pm
Reply with quote

Hello,

When you think of Binary numeric values, think of COMPutational "PICtures". . .

Also, at the top of the page is a link to "IBM Manuals". The first group is for COBOL. In the Language Reference is a comprehensive explanatoin of numeric data formats.

Those manuals are among your best resources and are both free and always available (especially if you download them to your local environment periodically).
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 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts SMF Record Date conversion failing CLIST & REXX 1
No new posts Assembler class assignment: stuck on ... PL/I & Assembler 12
Search our Forums:

Back to Top