LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting 4 binary bytes (string format) into a single U32 bit value

I am trying to convert a string of 4 characters in binary format into a single 32 bit value. I can use the convert string to byte array, and this works to give me 4 individual byte values. I want to take all 4 bytes and convert them into a single 32 bit value.
Thanks,
0 Kudos
Message 1 of 6
(5,064 Views)
Hi

If you pass the string into "Unflatten from String" and connect a U32 to the type input you should get a 32 bit output.
0 Kudos
Message 2 of 6
(5,055 Views)
Assuming your 4 byte string is in big-endian order (is it?), you can just typecast it directly to a U32. (see attached code image).
0 Kudos
Message 3 of 6
(5,047 Views)
If it is NOT in big endian order, then you can use Join Numbers (Advanced - Data Manipulation palette) to join the bytes in the correct order. First join the two MSBytes(U8) together to form U16 upper, then the two LSBytes(U8) together to form U16 lower, then use join numbers to join the two U16s to form a U32.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 6
(5,038 Views)
here is my little vi I use in this case
right the way tbob noted
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 6
(5,006 Views)
Thank you all for your feedback.
0 Kudos
Message 6 of 6
(4,987 Views)