Jump to content

Represent Hex data to Integer


Manoj Chaurasia

Recommended Posts

Hi

 

I'm trying to create a calculated column with integer values from hex.

 

Step 1. Create a calculated column from a long string only representing hex values.

Code: concatenate("0x",Mid([sequence sheet],218,2))

Hexarray = [0x0, 0x1, 0x2 ... 0xA, 0xB, 0xC]

 

Step 2. Convert to integer to represent the data in a sorted manner

Code; integer([Hexarray])

Returns empty

 

I have tested the following which works:

1. integer(0xF) = 15

2. integer(string(0xF)) ) = 15

 

But this doesn't

3. integer(concatenate("0x","F")) = empty

 

Can someone explain to me why 2 works but not 3

 

Thanks in advance

Michael

Link to comment
Share on other sites

Hi Michel,

 

I expressed myself badly. When I wrote return a string, is one string with no number characters (in that case, the "x"), so the result is an error and spotfire treat as an empty value.

 

I agree with you, a tool like spotfire needs to convert a string in hex.

 

I think you can use the IronPython to do that. Can you give me more details for the use of the cast (string to hex)

 

Regards,

 

Jorge

Link to comment
Share on other sites

Hi Jorge

 

When I realized that it couldn't be done I just opened the file in excel and created a new column which was equal to what I wanted to do in Spotfire (=HEX2DEC(TRIM(MID(K2;218;2)))).

 

It's not optimal but it works for my needs.

 

Using ironpython was new to me, it looks intresting and easy enough. I might look into it more in the future. Thanks for the tip.

 

Regards

Michael

Link to comment
Share on other sites

  • 2 years later...
  • 3 years later...

Hi

Great!! this action!!

Function Dec2hex works.

But back not, numbers are copied, chars are ignored.

I hope that this example is clear...

In excell I started with a number, then dec2hex then hex2dec then in SF dec2hex and dec2hex

DecHexDec (2)SF-HEXSF-DEC

16 10 16 10 10

29 1D 29 1D

64 40 64 40 40

123 7B 123 7B

I used:

Hex2Dec

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...