www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/03/20:39:53

Date: Wed, 3 Feb 1999 20:39:02 -0500 (EST)
From: Daniel Reed <djr AT narnia DOT n DOT ml DOT org>
To: djgpp AT delorie DOT com
Subject: Re: Re[2]: what is wrong with this?
In-Reply-To: <10991.990203@flashback.net>
Message-ID: <Pine.LNX.4.05.9902032034410.31847-100000@narnia.n.ml.org>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Wed, 3 Feb 1999, anarko wrote:
) #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
Damn, if I understand what you want to do, you took an insanely
complicated route to do it.

) RBIT(c,b)    resets bit 'b' in char c
To turn the b bit in byte c off, use:
#define RBIT(c,b)	((c) &= ~(b))

) 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 :-)
To turn the b bit in byte c on, use:
#define SBIT(c,b)	((c) |= (b))

-- 
Daniel Reed <n AT ml DOT org>
Madness takes its toll; please have exact change.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019