We all know that the logical short circuits of the && operator are if the left operand is false , because we know that if one operand is false , then the result is also false .
Why is the bitwise operator & not closing too? If the left operand is 0 , then we know that the result is also 0 . Each language I tested this in (C, Javascript, C #) evaluates both operands instead of stopping after the first.
Is there a reason why it would be a bad idea to let the & operator short-circuit? If not, why don't most languages do short quotes? This seems like an obvious optimization.
source share