Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
CICS fan

New User

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

 Posted: Mon Dec 21, 2009 12:43 pm    Post subject: Hexadecimal conversion 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.

dbzTHEdinosauer

Global Moderator

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

 Posted: Mon Dec 21, 2009 2:22 pm    Post subject: 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).
Escapa

Senior Member

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

 Posted: Mon Dec 21, 2009 2:25 pm    Post subject: What have you done so far? Have you tried searching forum. similar was discussed around month back.
CICS fan

New User

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

 Posted: Mon Dec 21, 2009 2:38 pm    Post subject: 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.
Robert Sample

Global Moderator

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

Posted: Mon Dec 21, 2009 3:56 pm    Post subject:

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.
CICS fan

New User

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

 Posted: Mon Dec 21, 2009 3:59 pm    Post subject: didnt mean to offend anyone, just was trying to see if someone can direct me to the solution. I could not understand it yet
Bill O'Boyle

CICS Moderator

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

 Posted: Mon Dec 21, 2009 5:07 pm    Post subject: Reply to: Hexadecimal conversion 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
dbzTHEdinosauer

Global Moderator

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

 Posted: Mon Dec 21, 2009 5:25 pm    Post subject: 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.
dick scherrer

Site Director

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

 Posted: Mon Dec 21, 2009 8:24 pm    Post subject: 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).
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Conversion of DLI update Jobs as BMP ... Gopinath Shanmugam IMS DB/DC 3 Wed Dec 20, 2017 12:02 pm Conversion of UTF-8 to EBCDIC muralikrishnan_new COBOL Programming 1 Tue Nov 21, 2017 5:33 pm Mainframe Blocks to Tracks conversion upendrasri JCL & VSAM 1 Sat Nov 18, 2017 10:52 am File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us