Trying to do ASCII LRC calculation, so I have hex values stored in a QByteArray, something in the lines of 01050500FF00, I need to add these values together, then subtract the result from FF, and add 1 to get the LRC..
in short :
1- Step1 = Sum Hex bytes of given QByteArray
2- Step2 = "FF" - Step1 (take the right part)
3- Step3 = Step2 + 1
Example :
1 - "01050500FF00", LRC should be F6
0+1+0+5+0+5+0+0+F+F+0+0 = 010A
FF - 0A = F5
F5 +1 = F6
2 - "010505000000", LRC should be F5
ie 0+1+0+5+0+5+0+0+0+0+0+0 = 0B
FF - 0B = F4
F4 + 1 = F5
My question is there an easy way to do Hex addition and subtraction in QT? if so how? or do I convert to decimal... case 'A' : a[i] = 11;break;... and so on..
tnx for any help..
p.s. C++
Bookmarks