You may have seen 'boolean' as a type in programming languages. Boolean types hold the value true or false. You may have seen operators like and, or, not or &&, ||, !. These all relate to boolean logic.

In software programs the boolean data type is primarily used with conditional statements (e.g. if statement). The program takes different actions depending on whether a boolean condition evaluates to true or false.

Boolean operators are implemented in all programming languages. Specialized scripting languages, shell script and database query language (SQL) also support boolean operators in some form.

The word 'boolean' comes from a person named George Boole, who defined this algebraic system of logic. We can understand the concept of boolean logic by studying the below truth tables for the various operators:

Truth Tables for AND, OR, NAND, and XOR
Truth Tables for AND, OR, NAND, and XOR

For boolean operators the output or the result is solely based on the inputs. If we think of 1 as true  and 0 as false, these values make sense intuitively. Let's look at AND — true AND true is true but for all other combinations where one of the inputs is false, the output is false. This makes sense logically.

The logic is different for OR — the result is only false when both inputs are false. In all other cases, where there is at least one input that is true the result is true.

NAND means Not AND. The result is the inverse of the result column for the AND truth table above — true becomes false and false becomes true. That's all.

XOR stands for eXclusive OR. XOR is slightly different than any of the other operators — the result is only true when both inputs are different from each other. So if A is true and B is false or vise versa, the result is true. And if both A and B are the same — either both true or both false — then the result is false.

So what is this boolean logic good for? The truth tables for boolean operators are implemented into logic gates. A logic gate is an electronic device implementing a logical operation on one or more binary inputs that produces a single binary output.

Logic Gates AND, OR, NAND, and XOR
Logic Gates AND, OR, NAND, and XOR

Logic gates are combined to make logic circuits. Logic circuits such as arithmetic logic units (ALUs), computer memory, all the way up complete microprocessors (containing 100 million gates). Logic gates are fundamental building blocks of computer hardware.

Both web and mobile operating systems, as well as browsers and all other software programs we write ultimately execute on a processor of some computer consisting of integrated circuits composed on logic gates.

***
Now you know the concept of Boolean Logic and how it relates to computer hardware. You can start to see the connection between boolean operators in software programs with logic gates used to build computer hardware.