This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hexadecimal Arithmetic

I want to carry out following Hexadecimal Arithmetic operation using C code

Multiplication......................................

char A[2] = { 0x01, 0x02};
char B[2] = { 0x03, 0x04};

I want to carry out multiplication operation and store result in variable C,
char C[3] = A * B

I expected the result in C as, C[3] = {0x03, 0x0A, 0x08};

I dont want to use unsigned int or unsigned long variable as i want to extend above mentioned multiplication operation for any size of A and B like A[16] * B[16] = C[32]

Division..............................................
char A[2] = { 0x01, 0x02};
char B[2] = { 0x03, 0x04};

char C[2] = B / A

I expected the result in C as, C[2] = {0x00, 0x02};

Modulus...............................................
char A[2] = { 0x01, 0x02};
char B[2] = { 0x03, 0x04};

char C[2] = B % A

I expected the result in C as, C[2] = {0x01, 0x00};

I am looking for some basic C code, so i can quickly adopt same in my application.

0