View Single Post
MATLABdude is offline
Aug28-11, 04:56 AM
Sci Advisor
P: 1,724
Quote Quote by rama1001 View Post
I had read some descriptions about these on web but i fell, both doing same thing. More, i observe these are changing language to language. Can any tell me straight difference with example.. that would be helpful to me.
Consider A, 0101, and B, 0110. The result of a logical AND of A and B would return TRUE, as you're ANDing two things that are non-zero. The result of a bitwise AND of A and B would return 0100. When you're dealing with booleans, or integers that are basically booleans, then yes, you'll have the same result.

Bitwise operators are really useful when you need to do bit-masking or low-level operations (or, so I'm told, to pass one of the "skill-testing questions" that HR departments love, but the solution for which has become so popularized via the interwebs that it's become banal).

If you restrict the use of logical operators to logical operations (when you have a few things that are either TRUE or FALSE, and you want an answer that's TRUE or FALSE), then you'll be in good stead.

EDIT: In short, bitwise: bit-by-bit. Logical: the whole thing.