Boolean Values and Truth Tables
What you'll learn: How computers use TRUE and FALSE to make decisions, and how to map out every possible outcome of a logical operation.
What Are Boolean Values?
In computing, a Boolean is the simplest data type—it can only be one of two values: TRUE or FALSE. Think of it like a light switch: it's either ON (TRUE) or OFF (FALSE).
Just like binary uses 1s and 0s to represent all numbers, Boolean logic uses TRUE and FALSE to represent all logical decisions. In fact, computers often store TRUE as 1 and FALSE as 0 in binary.
What Is a Truth Table?
A truth table is a chart that shows all possible combinations of Boolean inputs and their resulting outputs for a logical operation. It's like a recipe card that tells you exactly what you'll get based on what you put in.
Basic Logical Operations
AND: TRUE only if both inputs are TRUE
A | B | A AND B
------|-------|--------
FALSE | FALSE | FALSE
FALSE | TRUE | FALSE
TRUE | FALSE | FALSE
TRUE | TRUE | TRUE
OR: TRUE if at least one input is TRUE
A | B | A OR B
------|-------|-------
FALSE | FALSE | FALSE
FALSE | TRUE | TRUE
TRUE | FALSE | TRUE
TRUE | TRUE | TRUE
NOT: Flips the value (TRUE becomes FALSE, FALSE becomes TRUE)
A | NOT A
------|------
FALSE | TRUE
TRUE | FALSE
Why This Matters
Every decision your computer makes—from "Is this password correct?" to "Should I display this pixel?"—boils down to Boolean logic. Truth tables let us predict and verify these decisions before writing complex programs.
Key Takeaway: Boolean values are the TRUE/FALSE building blocks of all computer logic, and truth tables systematically show every possible outcome of logical operations.