Converting from binary to hexadecimal using C18

Anthony_87

New Member
Dear all,

I need help in converting an unsigned char array[8] (that actually contains the binary bits) and convert it to a hexadecimal notation!!
for example I have something like that:
unsigned char data[8] = {0,0,1,1,0,0,1,1}
and i need a function to return the converted value 0x33

so is there any function in the C18 library that do the trick? if not, can someone help me with the code?

Thanks in advance
Best Regards
 
Something like,
Code:
total=0;
for(i=0;i<8;i++){
    total<<=1;
    total+=data[i];
}
should work.

Mike.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…