Skip to content
BetterDL

Boolean variable

Also called: binary variable, logic variable, Boolean value, logic value, switching variable

A named quantity, such as A or B, that can only ever be 0 or 1. In a circuit it stands for the signal on one wire.

A Boolean variable is a letter that stands for something that is either true or false, on or off, high or low. We write those two values as 1 and 0, and nothing else is allowed: no 2, no 0.5, no negative numbers.

In hardware, each variable is the signal on one wire. A switch is open or closed, a sensor is tripped or not, a button is pressed or not. That is why digital design starts here: once you name the wires, you can write down what a circuit does with an equation.

Variables are combined with three operators, AND, OR and NOT, to build a boolean expression. Because each variable has just two possible values, you can check any claim about them by trying every combination in a truth table: with n variables there are 2ⁿ combinations.

A variable can appear plain (A) or complemented (). Each of those appearances is called a literal.

0000
0101
1001
1111

Worked example

Example

Naming the wires of a simple alarm

A garage light should turn on when it is dark and motion is detected.

  1. 1.

    Choose one variable per input: D = 1 means dark, M = 1 means motion.

  2. 2.

    Each one is a Boolean variable, because each condition is simply true or false.

  3. 3.

    The light needs both, so L = .

  4. 4.

    There are 2 variables, so 2² = 4 input combinations to consider: DM = 00, 01, 10, 11. Only 11 turns the light on.

Common mistakes

  • Treating a variable like an ordinary number. In Boolean algebra A can only be 0 or 1, so there is no such thing as 2A or A².

  • Thinking is a separate, independent variable. It is always the opposite of A, so it changes whenever A does.

Practice Boolean variable

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Boolean variable is taught in Boolean Algebra.