On Wed, 2008-08-20 at 14:44 +1000, Adelle Hartley wrote:
> Hi all,
> 
> I have what I think should be a simple C++ question.
> 
> What is the simpler way of writing this:
> 
>    int b = a;
>    if ((b & C)==C)
>    {
>      b = b - C;
>    }
> 
>    switch (b)
>      ...

is C guaranteed to be a single bit?
if yes,

        switch (a & ~C)

if no

        switch ((a & C) == C ? (a & ~C) : a)

_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to