Date: Wed, 3 Feb 1999 16:59:50 +0100 From: anarko X-Mailer: The Bat! (v1.19) S/N 9FA473A9 X-Priority: 3 (Normal) Message-ID: <15708.990203@flashback.net> To: djgpp AT delorie DOT com Subject: what is wrong with this? References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hello everybody, i have a little problem, i wrote a little routine that resets a specific bit in a char, and it worked fine. then i just wanted to reduce the lines of code it was written in to one line or something and it doesnt work correct, i reduced it to: bittmp = tmp << 2; bittmp = ((tmp >> 7) << 7) | (bittmp >> 2); without problems, but when i wrote it to: bittmp = ((tmp >> 7) << 7) | ((tmp << 2) >> 2); it did no longer work (it returned 11111111 binary, as i inputted in it) the code is below if someone wants to take a peek at it: #include #include void ToBin8(unsigned char numb); int main () { unsigned char tmp; unsigned char bittmp; tmp=0xFF; //11111111 in binary ToBin8(tmp); printf("\n"); //reset bit 6 bittmp = tmp << 2; bittmp = ((tmp >> 7) << 7) | (bittmp >> 2); // bittmp = ((tmp >> 7) << 7) | ((tmp << 2) >> 2); //this line isnt working ToBin8(bittmp); printf("\n"); return 0; } void ToBin8(unsigned char numb) { unsigned char cnt,a; int tmp; cnt = 128; for(a=0; a<8;a++) { tmp = numb - cnt; if (tmp >= 0) { printf("1"); numb = tmp; } else printf("0"); cnt = cnt / 2; } } /* ToBin8(uchar numb) */