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 

Converting hex values to decimal

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Mon Jul 08, 2024 7:25 am    Post subject: Converting hex values to decimal Reply with quote

This seems strange to me and I must be missing something that's ridiculously simple, but for the life of me, I can't find it.
Code:

select hex(24) from sysibm.sysdummy1    ;

shows the hex value 18 as I would expect.

But how do I do the reverse, ie, take the value 18 (assumed to be hex) and convert it to decimal (24).

I'll keep on testing, experimenting, but so far I haven't got anything to work.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jul 08, 2024 3:21 pm    Post subject: Reply with quote

misi01,

You seem to forget the solutions you got recently. In the previous thread titled "Displaying binary data as "readable" such" I pointed a link. here is that post


https://www.mvsforums.com/helpboards/viewtopic.php?p=64274#64274

This is the specific text that I am referring to

Kolusu wrote:
You can display X'40' as space if you follow the procedure list here (3rd solution)
https://mvsforums.com/helpboards/viewtopic.php?p=11074#11074

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Thu Jul 11, 2024 12:03 am    Post subject: Reply with quote

I didn't forget, but maybe you misunderstood my question?

The original post and this one can be simply illustrated with the following Rexx script.
Code:

str_b = 'F1F2F3'       
say str_b' 'x2c(str_b)
str_b = '0018'         
say str_b' 'x2d(str_b)

with the results being shown as
Quote:

F1F2F3 123
0018 24

The original post was a question on, basically, how to perform the equivalent of Rexx's X2C, whereas this one is how to perform the equivalent of Rexx's X2D.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 11, 2024 11:30 am    Post subject: Reply with quote

misi01 wrote:
I didn't forget, but maybe you misunderstood my question?


Misi01,

I did not misunderstand your question. First off you did not mention about replicating the REXX functions as you merely asked for "Converting Hex values to decimal" quoting the example of "select hex(24)"

Now your example Hex value of Decimal 123 is X'7B' and binary bits it is 01111011

Code:

SELECT HEX(24)  AS   HEXVALUE_1
      ,HEX(123) AS   HEXVALUE_2
  FROM SYSIBM.SYSDUMMY1;       
---------+---------+---------+--
HEXVALUE_1  HEXVALUE_2         
---------+---------+---------+--
00000018    0000007B             


So the SQL that I showed converts X'7B' to 123 and X'18' to 24 but however, X'F1F2F3' results in a decimal of 15856371 which is NOT what you want.

Your need to convert character HEX data to decimal doesn't translate the same way.

Run the SQL shown in that post with X'0000007B' and X'00000018' and you will get the result as 123 and 24 respectively.
_________________
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 -> Database 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