#include
unsigned char swap_nibbles(unsigned char c)
{
unsigned char temp1, temp2;
temp1 = c & 0x0F;
temp2 = c & 0xF0;
temp1=temp1 << 4;
temp2=temp2 >> 4;
return(temp2|temp1); //adding the bits
}
int main(void)
{
char ch=0x34;
printf("\nThe exchanged value is %x",swap_nibbles(ch));
return 0;
}
Saturday, December 5, 2009
To swap the two nibbles in a byte
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment