Slide 3.10: Character storage (cont.)
Slide 4.1: Programming Laboratory I: searching a string for a character
Home

Boolean Operations


Boolean algebra, which could be used in programming to express logical operations, defines a set of operations on the values true and false.

Boolean Expression
A boolean expression involves a boolean operator and one or more operands. Each boolean expression implies a value of true or false. The most common Boolean operators are AND (∧), OR (∨), and NOT (¬).

X Y X AND Y
F F F
F T F
T F F
T T T
X Y X OR Y
F F F
F T T
T F T
T T T
X NOT X
F T
T F

In a boolean expression involving more than one operator, the NOT operator has the highest precedence, followed by AND and OR. May use parentheses to avoid any ambiguity.

Truth Tables for Boolean Functions
A boolean function receives boolean inputs and produces a boolean output. A boolean table lists all possible combinations of inputs and the corresponding output of a Boolean function.

X Y Z   Y OR Z X AND (Y OR Z)   X AND Y X AND Z   (X AND Y) OR (X AND Z)

For convenience, you could use 1 for T and 0 for F.