??? 08/03/09 12:31 Read: times |
#168103 - 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. |
Topic | Author | Date |
Hexadecimal Arithmetic | 01/01/70 00:00 | |
Cross-post | 01/01/70 00:00 | |
C is really unsuited for this purpose. | 01/01/70 00:00 | |
RE: 'C' does not allow access to the carry flag | 01/01/70 00:00 | |
That shoots down the reason to use C: | 01/01/70 00:00 | |
hexadecimal arithmetic | 01/01/70 00:00 | |
You already have answers to that question!![]() | 01/01/70 00:00 |