Logical Operators

Logical operators work on Boolean (true/false) values. These values often come as Boolean Constants and Comparison Operators.

Logical Operators
OperatorNameExampleComments
NOTLogical NegationNOT a
ANDLogical Conjunctiona AND b
ORLogical Disjunctiona OR b
XORLogical Exclusive Disjunctiona XOR b
Not

Also known as Boolean negation.

not truefalse
not falsetrue
And

Also known as a Boolean product.

false and falsefalse
false and truefalse
true and falsefalse
true and truetrue
Or

Also known as Boolean addition.

false or falsefalse
false or truetrue
true or falsetrue
true or truetrue
Xor

The exclusive or. “You can have you cake XOR you can eat it.”

false xor falsefalse
false xor truetrue
true xor falsetrue
true xor truefalse