LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert 1D u16 array into 1D u8 array.

Hi.
Can I convert a 1D array of U16 into
a 1D array of U8?

Thank you,
Van
0 Kudos
Message 1 of 7
(6,613 Views)
Yes. However, if you wish to keep your original array, all values in your array need to be less than 255. Otherwise, LV will only take the last 8 bits of the U16 number and convert to U8, which will not match your original array.
0 Kudos
Message 2 of 7
(6,613 Views)
Are you wanting two U8 for every U16 or just one?

Les
0 Kudos
Message 3 of 7
(6,613 Views)
Thanks David.

Van
0 Kudos
Message 4 of 7
(6,613 Views)
I need two U8 for each U16.

Van
0 Kudos
Message 5 of 7
(6,613 Views)
To convert an U16 array to an U8 Array of twice the length, just use typecast.

Wire the U16 array input on the left, and an empty U8 array to the "type" terminal on top. On the right, you'll get the new U8 Array.

(If the U16 array originates from the outside you also might need to know if it is little-endian or big-endian in order to know how to interpret the resulting U8 array.)
Message 6 of 7
(6,613 Views)
Thank you Altenbach.
I appreciate it.

Van
0 Kudos
Message 7 of 7
(6,613 Views)