Reputation: 439
I am storing some hex values inside a char array. I would like to sum these hex values and if it is bigger than 1 byte then it should drop the larger bits.
For example I might declare char a = 0x21; char b = 0x07;
and so I would like to add them to get a hex value of 0x28 as it should be, which is stored as a char.
Upvotes: 1
Views: 884
Reputation: 439
Thanks tkausl. It made me realise the answer will be in int type, and I was confused why it gave me 40.
I was looking for char(a+b).
Upvotes: 1