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.
INPUT | OUTPUT |
true | false |
false | true |
AND ( && )
A logical AND returns false unless ALL inputs are true. The truth table for a two-input logical AND is displayed below.
INPUT A | INPUT B | OUTPUT |
false | false | false |
false | true | false |
true | false | false |
true | true | true |
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 A | INPUT B | OUTPUT |
false | false | false |
false | true | true |
true | false | true |
true | true | true |