Author |
Message
|
Subhjeet Samal |
Posted: Thu May 16, 2019 4:29 am Post subject: IIB 10.0.0.13 Hexadecimal to Binary and vice versa mechanism |
|
|
Newbie
Joined: 16 May 2019 Posts: 3
|
How to convert 64 bit hexadecimal into hexabinary and after conversion, how to take the first 48 bits out of the 64 bit converted hexabinary and convert that back to hexadecimal? I have tried using ASBITSTREAM and CAST functions but nothing working. I am using IIB v10.0.0.13.
Last edited by Subhjeet Samal on Fri May 17, 2019 3:14 am; edited 1 time in total |
|
Back to top |
|
 |
timber |
Posted: Thu May 16, 2019 5:47 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Not sure what you mean by '64 bit hexadecimal'. Do you mean base64?
Please supply the input, your required output and the code that you are currently using.
For bonus points, use [code] blocks for the inputs/outputs and any code. Much easier for us to read. |
|
Back to top |
|
 |
Subhjeet Samal |
Posted: Fri May 17, 2019 2:50 am Post subject: |
|
|
Newbie
Joined: 16 May 2019 Posts: 3
|
PLeease find the below esql code i tried for the same :
Code: |
DECLARE LogLogid INTEGER FIELDVALUE(InputRoot.XMLNSC.*:DataEventSet.*:dataEvents.*:id); //4750389086465 is a input hexadecimal number
DECLARE Lcnt,Ldecode,Wcnt1,LoggerID INTEGER ;
DECLARE LogLogidb, Wtid, Wnv1 BIT;
SET LogLogidb = CAST(LogLogid AS BIT);
set Ldecode = cast(LogLogidb AS INTEGER);
SET Lcnt = LENGTH(LogLogidb);
SET LogLogidb = LEFT(LogLogidb,48);
SET Lcnt = LENGTH(LogLogidb);
SET Wtid = 0;
SET Wnv1 = Wtid || LogLogidb ;
SET Wcnt1 = LENGTH(Wnv1);
SET Wnv1 = RIGHT(Wnv1,64);
SET Wcnt1 = LENGTH(Wnv1);
DECLARE ff CHARACTER '0xFFFFFFFFFFFF0000';
SET LoggerID = cast(Wnv1 AS INTEGER FORMAT ff); // getting 72485185 but the expected hexadecimal value is 4750389084160 |
RESULT:
input hexadecimal value is = 4750389086465 (InputRoot.XMLNSC.*:DataEventSet.*:dataEvents.*:id)
getting the output is (LoggerID =72485185) but the expected output is 4750389084160
which our front end .NET application getting correctly as below. We are trying the same in esql to achieve
The same is achived by our front end .NET team with below .NET code :
ulong result = id & 0xFFFFFFFFFFFF0000;
return result;
RESULT :
input is id = 4750389086465
output result = 4750389084160
id and result are hexadecimal numbers |
|
Back to top |
|
 |
Subhjeet Samal |
Posted: Fri May 17, 2019 2:56 am Post subject: |
|
|
Newbie
Joined: 16 May 2019 Posts: 3
|
Our input and outputs are hexadecimal numbers :
example :
for 4750389086465 inpu hexadecimal number we are expecting 4750389084160 output hexadecimal number .
4750389086465: 0000 0000 0000 0100 0111 0101 0000 0011 1000 1001 0000 1000 0110 0100 0110 0101
4750389084160: 0000 0000 0000 0100 0111 0101 0000 0011 1000 1001 0000 1000 0100 0001 0110 0000
we are trying to convert the hexadecimal number(4750389086465) to hexabinary . After take first 48 bits and then convet the same back to hexadecimal number (4750389084160) |
|
Back to top |
|
 |
timber |
Posted: Fri May 17, 2019 4:51 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
|
Back to top |
|
 |
|