Focal Point
[Closed] Hexadecimal to Decimal

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7147064386

August 17, 2016, 08:29 AM
Avatar
[Closed] Hexadecimal to Decimal
Hello,

I'm looking for some advise on converting Hex to Decimal values.

Something like '073D7AAE' needs to be converted to it's corresponding decimal '121469614'.

I want to perform this as a define or user function instead of creating temporary file for lookup.

Thanks in advance.

This message has been edited. Last edited by: Avatar,


WebFOCUS 8
Windows, All Outputs
August 17, 2016, 08:31 AM
Tom Flynn
Search on Hexadecimal and the answer will be there...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 17, 2016, 08:48 AM
Avatar
Yes, I was able to find that before.

But like I requested, I'm wondering if there is any way to skip creating the look up file and simple way to get decimal value. Just like UFMT gives hex value.


WebFOCUS 8
Windows, All Outputs
August 17, 2016, 12:21 PM
Hallway
I was able to convert Hex to Dec when using a SQL pass-through. You just need to make sure that you add a '0x' to the front of your HEX as you can see I did in the &SQLHEX variable:

 
-DEFAULTH &MYHEX = '073D7AAE'
-SET &SQLHEX = '0x' | &MYHEX;

ENGINE SQLMSS SET DEFAULT_CONNECTION YOUR_SERVER_NAME
SQL SQLMSS PREPARE SQLOUT FOR

SELECT '&MYHEX' AS HEX, CONVERT(INT, &SQLHEX.EVAL) AS DEC

END

TABLE FILE SQLOUT
PRINT *
END 



I'm sure that you could use the DB_EXPR function if you don't want to use a SQL Pass-through.


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs: