Can anyone help and let me know how can I reverse a Binary number, please ASAP.
What I mean is if I get 00000001 00000010 00000010 I should get as a result: 10000000 01000000 01000000.
void reverse_bit(unsigned char x, char *pt)
{
int t, i;
unsigned char hold;
char temp[8];
char tmp_bin[8];
char *pt2=0;
tmp_bin[0]='\0';
pt2 = tmp_bin;
display_binary(x, pt2);
hold = x;
for(t=1; t <count; t++)
{
if(hold & HIGH_BIT)
hold = ( hold << 1 | 1);
else
hold = hold << 1;
display_binary(hold, pt2);
}
x = hold;
strcpy(temp,"");
for(i = HIGH_BIT; i > 0; i = i/2)
{ if(x & i)
sprintf(temp, "%s1", temp);
else
sprintf(temp, "%s0", temp);
}
strcpy(pt,temp);}
this is what i did and it does not work.