delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/10/17:51:31

Message-ID: <35883781.8B19EC6B@go.ro>
Date: Thu, 18 Jun 1998 00:39:13 +0300
From: Radu Georgescu aka skoola <skoola AT go DOT ro>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: bits and flags
References: <01beca3f$da040700$LocalHost AT thendren>
Reply-To: djgpp AT delorie DOT com

> >If you take 2 to the 4th power witch is 16, you can say:
> >
> > ch-=16;
> >
> >and that will turn of the 4th bit if it is on.  If it is off and you want
> it on
> >you can go
> >
> > ch+=16;
> >
> >so basicly you add or subtract 2 to the power of the bit you want.

that's not true.
to turn on bit #n :
ch=ch|(1<<n)
to turn off:
ch=ch&(1<<n)
where 0<=n<=7

- Raw text -


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