Mon. Jan 23rd, 2023

Boolean Operators

Boolean operators are those that deal with true and false values. For the purpose of this course, you should understand the use of NOT, AND and OR.

NOT ( ! )

The simplest boolean operator, NOT inverts the value supplied. The truth table for a NOT gate is shown below.

INPUTOUTPUT
truefalse
falsetrue

AND ( && )

A logical AND returns false unless ALL inputs are true. The truth table for a two-input logical AND is displayed below.

INPUT AINPUT BOUTPUT
falsefalsefalse
falsetruefalse
truefalsefalse
truetruetrue

OR ( || )

A logical OR returns false only if all inputs are false. If one or more of the inputs are true, then the output is true. The truth table is below.

INPUT AINPUT BOUTPUT
falsefalsefalse
falsetruetrue
truefalsetrue
truetruetrue