05-10-2014 05:48 AM
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?
Solved! Go to Solution.
05-10-2014 07:39 AM
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.
05-10-2014 07:51 AM
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
05-10-2014 08:27 AM
here is an example of what I mean, the result is x54 when it should be x154
05-10-2014 10:03 AM - edited 05-10-2014 10:06 AM
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.