This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bit Operator

Hi ,

A "bit" of a fundamental query.

Suppose I declare two bit variables
bit MyBit1,MyBit2;

I need to do something if both bits are 1.

Are these two methods equivalent:

if(MyBit1 & MyBit2) // Logical &
{ do something....
}

if(MyBit1 && MyBit2) // Conditional &&
{ do something....
}

Thomas

Parents
  • "Thanks" to you choosing to make a secret out of what platform you're talking about, and by implication, what "bit" actually is, it's impossible to answer that.

    Anyway, it doesn't matter. Write what you mean, and let the compiler handle the rest. In the case at hand, that would be the '&&'

Reply
  • "Thanks" to you choosing to make a secret out of what platform you're talking about, and by implication, what "bit" actually is, it's impossible to answer that.

    Anyway, it doesn't matter. Write what you mean, and let the compiler handle the rest. In the case at hand, that would be the '&&'

Children
No data