From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add up hex bytes to form a word

Solved!
Go to solution

What is the easiest way to add up hex digits in a string to form a word.

 

I am currently using the string to byte array and then the array elements, but this returns a byte only, i.e.xAA + xAA = x54

how do I return the full word which would be x0154 in this case?

 

 

0 Kudos
Message 1 of 5
(3,390 Views)

This addition can be done the way normal addition does. One thing you need to set is display type. 

For this right click on control select radix from visible item and change it to hex. 

CLAD
Passionate for LabVIEW
0 Kudos
Message 2 of 5
(3,377 Views)

I do not understand your question. Do you want to split your string into groups of two characters, convert each pair of characters to a number, and then add the numbers? Are all the strings the same length? What if there is an odd number of characters?

 

Please show a more general example than AA and AA.

 

Lynn

0 Kudos
Message 3 of 5
(3,371 Views)

here is an example of what I mean, the result is x54 when it should be x154

 

hex byte addition.png

0 Kudos
Message 4 of 5
(3,364 Views)
Solution
Accepted by hydzik

You can't have a hex value of 154 in a U8 byte because you don't have enough bits.

 

Take your U8 array, and use the To U16 conversion bullet found on the Numeric >> Conversion palette.  That will give you enough bits so that you can add two U8's and not roll over.

 

Message 5 of 5
(3,339 Views)