Is any direct function is available for the complement of the char variable
the OP mentioned "this is about a bit" so, let us make it about a bit and we'll earn money when being paid per line of code:
U8 ComplementChar(U8 Phred) { if (Phred & 0x01) { Phred &= 0xfe; } else { Phred |= 0x01; } if (Phred & 0x02) { Phred &= 0xfd; } else { Phred |= 0x02; } if (Phred & 0x04) { Phred &= 0xfb; } else { Phred |= 0x04; } if (Phred & 0x08) { Phred &= 0xf7; } else { Phred |= 0x08; } if (Phred & 0x10) { Phred &= 0xef; } else { Phred |= 0x10; } if (Phred & 0x20) { Phred &= 0xdf; } else { Phred |= 0x20; } if (Phred & 0x40) { Phred &= 0xbf; } else { Phred |= 0x40; } if (Phred & 0x80) { Phred &= 0x7f; } else { Phred |= 0x80; } } // end ComplementChar
Erik
Are you sure the OP meant complement and not compliment? Complimenting a charcter would change the whole dynamic of the function and might make a lot more sense. For example:
char *GetComplimentOfAChar (char c) { if (c < 0) return ("You look very pretty today."); if (c < 64) return ("My, you're a handsome character."); return ("My, what a big character you are."); }
:-)
Jon
the OP mentioned "this is about a bit"
Maybe a function that copies a char to a bdata variable and then inverts each bit separately ? Might be fun.
Hm, maybe the OP can try this:
sbit ACC_0 = ACC^0; unsigned char getComplement(unsigned char input) { register unsigned char i = 8; ACC = input; do { ACC *= 2; ACC_0 = CY ? 0 : 1; } while(--i); return ACC; }
warning: the code above is strictly non-ansi and non-portable.