Possible Duplicate:
Why ‘&&’ and not ‘&’?
When would I use a bit-wise AND and normal AND?
I read the bit-wise AND is good for applications that have a memory limit.
Which one will be the best to use then, overall?
if (true & false)
{
}
or
if (true && false)
{
}
Wouldn’t it be better to always use a bit-wise AND then?
Bitwise AND (
&) is a bitwise operation on both operands.&&instead, is a logical AND operation.This assumption is not correct. I can say that bitwise can be used in intensive calculus, for example in a CAD application kernel’s drawing procedure when you need to divide an absolute number by 2 (say), instead of using ordinary division which is slow, we use bitwise shift
>>. But these are extreme conditions and 99% of cases none will approve use of such techniques.So it’s basically about performance improvement and not memory.
They are completely different.