I need to implement an arithmetic algorithm for hexadecimal numbers. So I want every arithmetic operation i.e addition, multiplication, subtraction, and division to be performed in base 16.
Is there anyway to sort of set a base?
Please.
Modern computers work in binary, by directly operating on voltages that represent 1s and 0s. That's just they way they work, you can't change that in software.
What you can do is change the base used for I/O, so that you print out numbers in hexadecimal, for instance:
int a = 47, b = 95;
int c = a + b; /* Look, we add two integers! */
printf("%x + %x = %x\n", a, b, c); /* Print terms and sum in HEX. */
This will print:
2f + 5f = 8e
Note that the variables are initialized from decimal numbers, but we can still print the values in hex.