Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hexadecimal Calculus

Status
Not open for further replies.
Is there a C function which allow to do some calculation with hexadecimal values ? Simple addition...
For example, I would like to do this:

unsigned char BCheckSum;
BCheckSUm = 0x0E + 0x11 + 0x2D;

Thank's for advance
 
Yes, that would be

Code:
BCheckSum = 0x0E + 0x11 + 0x2D;

Base is an illusion created for the presentation of numbers. It makes no difference to the maths whether you express those numbers in base 10 or base 16 or whatever.

Code:
// same thing in bases 10, 16 and 8 respectively
a = 16 + 10;
a = 0x10 + 0xa;
a = 020 + 012;


--
 
you might want to use something a little bigger than an
unsigned char to hold sums. on many machines, the highest number you can hold is 256.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top