MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert HEX value to DECIMAL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
prasanav0947
Beginner


Joined: 27 Jul 2019
Posts: 2
Topics: 1

PostPosted: Wed Feb 10, 2021 8:56 pm    Post subject: Convert HEX value to DECIMAL Reply with quote

Hello,

Tried my best to get an answer from the manual and search engine. I am using DFSORT to do this.

I have a file that contains HEX values but I want to convert to decimal. For example:

Input file:
00000787
000008C8

Output file:
00000787 1927
000008C8 2248

-SS
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 11, 2021 8:15 am    Post subject: Reply with quote

prasanav0947,

You need to use UNHEX function to convert the hex value to binary. Once you convert to Binary then you can convert to Decimal. Something like this

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
00000787                                                       
000008C8                                                       
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC OVERLAY=(10:01,08,TRAN=UNHEX,                         
                 10:10,04,FI,EDIT=(SIIIIIIIIIIIT),SIGNS=(+,-))
/*


The output from this job would be
Code:

00000787         +1927
000008C8         +2248
Back to top
View user's profile Send private message Send e-mail Visit poster's website
prasanav0947
Beginner


Joined: 27 Jul 2019
Posts: 2
Topics: 1

PostPosted: Thu Feb 11, 2021 9:38 am    Post subject: Reply with quote

Very Happy

Thanks Kolusu. It worked perfectly.

I sincerely hope this in-place(?) conversion is documented in one of the DFSORT manuals. But, now I know that it can be done as you have stated clearly.

Thanks again.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 11, 2021 2:09 pm    Post subject: Reply with quote

prasanav0947 wrote:
Very Happy
I sincerely hope this in-place(?) conversion is documented in one of the DFSORT manuals. But, now I know that it can be done as you have stated clearly.


Prasanav0947,

We do not document destructive overlay of data. In this case I am overlaying the 4 byte content(Unhex) with a 13 byte Display value. So it would always have the right data. You also have to note that we might overlay other contents(if exists) at position 10. Since you just have the hex values in the first 8 bytes, I showed the value right next to hex value.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group