What is the difference between the Boolean & operator and the && operator?The Boolean && operator is used for determining two relational expressions and returns true if only if both returns true, otherwise returns false
The Boolean & operator is used to perform Boolean operations on bits of two given arithmetic expressions
Example: 5 & 6 will return 5. 5 and 6 will be converted into their binary equivalents 101 and 110 respectively. Now the comparison occurs for corresponding place value bits – 1 and 0, 0 and 1 and 1 and 1. This comparison returns 100, i.e. equivalent to 5.What is the difference between the Boolean & operator and the && operator?A & B In this, both the operands A as well as B are evaluated and then ‘&’ is applied to them.
A && B In this, A is evaluated first. If A is true then B is evaluated and then the operand is applied to them. If A is false, evaluation of B is skipped.
|