The following logical operators operate on boolean or integral operands, as noted.
|a&b||a bitwise and b||binary||& evaluates both of its operands and returns the logical conjunction (“AND”) of their results. If the operands are integral, the logical conjunction is performed bitwise.|
|a&&b||a and b||binary||&& operates on boolean operands only. It evaluates its first operand. If the result is false, it returns false. Otherwise, it evaluates and returns the results of the second operand. Note that, if evaluating the second operand would hypothetically have no side effects, the results are identical to the logical conjunction performed by the & operator. This is an example of Short Circuit Evaluation.|
||a bitwise or b||binary||
||a or b||binary||
|a ^ b||a x-orb||binary||
|!a||not a||unary||! operates on a boolean operand only. It evaluates its operand and returns the negation (“NOT”) of the result. That is, it returns true if a evaluates to false and it returns false if a evaluates totrue.|
|~a||bitwise not a||unary||~ operates on integral operands only. It evaluates its operand and returns the bitwise negation of the result. That is, ~a returns a value where each bit is the negation of the corresponding bit in the result of evaluating a.|