Hi,
I am programming a PIC controller and need to be able to do hexadecimal manipulation.
Here is my code in MikroC
[code]
int percentage percent_digit1, percent_digit2, percent_digit3;
percentage = 28;
percent_digit3 = percentage % 10;
percent_digit2 = percentage / 10;
if((percent_digit2 == 0) && (perccent_digit3 == 0) {
percent_digit1 == 1;
else
percent_digit1 == 0;
[code]
In my MikroC code I can do the following
Code:
char percent_digit3[1];
percent_digit3[0] = 0x08; //prints the ascii character corresponding to 0x08
which stores 0x08 as one byte.
I need to be able to take an integer and convert it to a hexadecimal number and store the hex in one byte of memory.
So if I take 28% I need to be able to convert and store 2 as a hex in one char variable lets say hex_1[1] and convert and store 8 as a hex in one char variable lets say hex_2[1]
Does anyone know how to do this?
Any help would be greatly appreciated