07-26-2022 03:11 AM
I've created a hexadecimal array. I need to convert it to signed integer
For example if I input 'ff48' into the array, I should get -184 as the output.
I tried creating a local variable from the Hexadecimal input and changing the representation to decimal, but then 'ff48' is being converting to unsigned integer, i.e., 65352.
Is there a way to do it?
I've also attached what I've done up till now.
Thanks.
Solved! Go to Solution.
07-26-2022 03:22 AM - edited 07-26-2022 03:25 AM
Hi sarwat,
@sarwatsarfaraz wrote:
I've created a hexadecimal array. I need to convert it to signed integer
No, you did not create an array. You placed a default scalar control on your frontpanel!
No, you don't need to convert to "signed integer", it already is a signed integer as you set the I32 datatype!
@sarwatsarfaraz wrote:
For example if I input 'ff48' into the array, I should get -184 as the output.
Set the datatype for both frontpanel elements to I16, then type FF48 into the control and run the VI:
07-26-2022 04:18 AM
This worked.
But why doesn't I32 show signed integer and I16 does?
07-26-2022 04:25 AM
Hi sarwat,
@sarwatsarfaraz wrote:
But why doesn't I32 show signed integer and I16 does?
Because FF48 (I16) is something completely different than 0000FF48 (I32)…
07-26-2022 06:19 AM
I need to join multiple elements of an array into a single element.
I've attached a picture of how i want it to be.
How can I do this?
07-26-2022 06:22 AM
Hi sarwat,
@sarwatsarfaraz wrote:
I need to join multiple elements of an array into a single element.
Several options:
07-26-2022 07:49 AM
@GerdW wrote:
4. When your array represent bytes then you might use UnflattenFromString…
You will need the Byte Array To String before the Unflatten From String. But do note that the Byte Array To String is literally a No Op (takes no clock cycles or memory) since an array of bytes and a string have the exact same data format.
I will also state that I try to avoid the Type Cast and prefer the Unflatten From String due to the additional options with the Unflatten From String.