Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting from binary to hexadecimal using C18

Status
Not open for further replies.

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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top