Date: Wed, 3 Feb 1999 23:48:23 +0100 From: anarko X-Mailer: The Bat! (v1.19) S/N 9FA473A9 X-Priority: 3 (Normal) Message-ID: <10991.990203@flashback.net> To: Eli Zaretskii Subject: Re[2]: 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 Hi Eli, onsdag, den 3 februari 1999, you wrote: > You forget that C promotes all integral data types to int's in an > expression. In other words, ((tmp << 2) >> 2) is a no-op, since tmp is > loaded into a 32-bit register, where the high two bits aren't shifted out > by the innermost parentheses. In the first example, the 2 high bits are > chopped off when you store the result of (tmp << 2) into an 8-bit > variable. yeah, i solved the problem later on, guess i was to quick to ask for help, thanks anyway :-) > Btw, to reset bit 6, which is what you seem to want, you don't need to go > to such great lengths. All you need is this: > bittmp = tmp & 0xCF; hm, this is not true, 0xCF = 11001111 in binary, i don't see how this could reset bit 6, in fact it doesnt, for example 0xFF & 0xCF = 11001111 0x10 & 0xCF = 00000000 well, i got the function working at least, here it is: #define RBIT(c,b) ((uchar) (c >> (1+b)) << (1+b)) | ((uchar) (c << (8-b)) >> (8-b)) #define SBIT(c,b,b2) (((uchar) (c << (8-b))) >> (8-b)) | (((uchar) (c >> (1+b))) << (1+b)) | b2 RBIT(c,b) resets bit 'b' in char c SBIT(c,b,b2) sets bit 'b' in char c, need to OR it with b2 also, wich is 0x1 for bit 0, 0x2 for bit 1, 0x4 for bit 2 etc.. i'm sure it can be solved more easy, but i'm not that talent in math so this is what i managed to code :-) /anarko --------------------------------------------------------- Personal homepage: http://www.flashback.net/~anarko/ PGP Public key: http://www.flashback.net/~anarko/pgp/anarko.asc ICQ UIN#: 3299208 (anarko)