LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert array of numbers to 1,0s and hex value

Hi I have an array of u32 numbers (all 0 or 1)  and I would like to convert them to 1,0s and hex value. could you please let me know how can I do it?

 

For example array of   "0" "0" "0" "1" "0" "0" "0" "0"   should give me   00010000 and 10(hex)

 

Thanks

0 Kudos
Message 1 of 3
(2,481 Views)

Lots of ways come to mind. To start with though, Why is your data coming in as a u32 array? Seems like a strange data format for 0s and 1s.

 

Scan into string with a loop is one way.

 

You can also do this bitwise by OR'ing in your inputs and using bit shifts.

 

You may just need to set the display mode of your indicators after you do the number assembly unless you actually need a string.

 

EDIT: Another messy way to do this would be to do comparisons to create a Boolean array and then do the Boolean Array to Number.

0 Kudos
Message 2 of 3
(2,457 Views)
  • Reshape to a 8 column 2D array.
  • Autoindex on a FOR loop
    • In the loop, do a !=0 to convert to a boolean array with 8 elements
    • convert boolean array to number (reverse array first if needed)
    • Autoindex to create output array
  • set numeric output array format to hex display (or format as hex string. It is not clear from your description what the output representation should be).
0 Kudos
Message 3 of 3
(2,450 Views)