RRB JE CBT2 : EXPERT
27 Jun

Difference Between Bitwise AND (&) and Logical AND (&&)

ParameterBitwise AND (&)Logical AND (&&)
PurposePerforms bit-by-bit comparisonChecks logical (true/false) conditions
Operates OnBinary bits of integersBoolean expressions or conditions
ResultInteger valueBoolean value (true/false or 1/0)
ConditionEach corresponding bit is comparedEntire expression is evaluated
Short-Circuit EvaluationNo (both operands are always evaluated)Yes (if first operand is false, second is not evaluated)
Used InBit manipulation, masks, embedded systemsDecision making (if, while, for)
Symbol&&&
Example5 & 3 = 1(5>3) && (4>2) = true
Output Example0101 & 0011 = 0001(10>5) && (8<3) = false
Comments
* The email will not be published on the website.