Note - bit-wise and is _not_ the same as logical and.
On Sat, 18 Mar 2006, Daniel Pettersson wrote:
> A tip.
>
> double the value for each flag, 1 2 4 8 etc
> ex:
> 1 + 4 = 00000101
>
> to check weither the flag has been set just use "and" ex: check for
> 4: isFlagSet = 4 & flags;
>
> it will become 1 if the flag is set and 0 otherwise
isFlagSet will become 4 if the flag is set, else 0.
To make it a logical expression (needed if isFlagSett is of type bool, or
if the expression is used to count up a variable with 1 if flag is set),
the following is needed:
isFlagSet = (4 & flags) != 0;
/Per W
|