Boolean logic – Binary Logic

Teach any GCSE Computer Science class

We have put together a full GCSE Computer Science curriculum that will give you all the teaching materials you need to teach any topic.

Whether you’re a brand new Computer Science teacher, or you’ve been teaching ICT for years, our resources will save you hours and hours of lesson preparation every single week.

View the resources →

Candidates should be able to:

  • explain why data is represented in computer systems in binary form
  • understand and produce simple logic diagrams using the operations NOT, AND and OR
  • produce a truth table from a given logic diagram.

Why is data represented in computer systems in binary form?

Computer systems are based on logic circuits. This type of circuit only has two states. For example, a current can either be flowing/not flowing or a switch can be either on/off. These two states are easily and reliably detected and transmitted by computer systems.

In computer systems data is represented in binary form because binary numbers are made up of only 2 digits (0/1) which means the two states of a logic circuit can easily represent/store a binary number (i.e. 0 = OFF and 1 = ON).

In computer storage, data is also easily stored in binary form as long as the storage media can represent the 2 different digits:

  • On magnetic media such as a hard drive these are represented by magnetising an area of the disk platter either North or South.
  • On optical media such as a CD/DVD/Blu Ray disk, these are represented by an area of the disk surface either reflecting or not reflecting a laser beam.

Every possible type of data such as numbers, text, audio, images, video etc. has to be converted (digitised) into binary form before it can be stored or processed by a computer system.

Conversion between denary (decimal) and binary:

Denary to binary conversionBinary to denary conversion
Denary number:
Binary conversion:
Binary number:
Denary conversion:

What are logic diagrams and how are they produced?

A logic gate performs a logical operation on one or more logic inputs and produces a single logic output. The logic used in computer systems is called Boolean logic because there are only 2 possible values, TRUE or FALSE (represented in binary as 1 or 0).

A logic diagram is a diagram that represents one or more of logic gates linked together to form a logic circuit.

In logic diagrams, symbols are used to represent logic gates, letters are used to label the input(s) and output(s) and lines are used to show how logic gates are connected.

The 3 basic logic gates are called AND, OR and NOT gates.

The symbols for the 3 basic logic gates
ANDORNOT
The logical AND symbol
The logical OR symbol
The logical NOT symbol
This logic gate has 2 inputs and 1 output.

The output is TRUE only if one input AND the other input is TRUE.

This logic gate can be written as a logic statement:

O = A AND B

This logic gate has 2 inputs and 1 output.

The output is TRUE if one input OR the other input isTRUE.

This logic gate can be written as a logic statement:

O = A OR B

This logic gate has 1 input and 1 output.

The output is TRUE if the input is FALSE and visa-versa.

This logic gate can be written as a logic statement:

O = NOT A

Examples of Logic Diagrams

A logic diagram that combines an AND and a NOT gate
A logic diagram showing an OR gate combined with a NOT gate
Logic diagram: O = (NOT A) AND B
In this logic diagram, the output will be FALSE onlywhen inputs A and B are both TRUE.

This logic diagram can be written as a logic statement:

O = NOT (A AND B)

This gate combination is known as a NAND gate and can be represented by the symbol shown below.

In this logic diagram, the output will be TRUE only when inputs A and B are both FALSE.

This logic diagram can be written as a logic statement:

O = NOT (A OR B)

This gate combination is known as a NOR gate and can be represented by the symbol shown below.

In this logic diagram, the output will be TRUE onlywhen input A is FALSE and input B is TRUE.

This logic diagram can be written as a logic statement:

O = (NOT A) AND B

 
The symbol for a NAND gate
 
The symbol for a NOR gate

The logic diagram below is for a circuit made up of AND, OR and NOT gates. It has 2 inputs (A and B) and 2 outputs (S and C). This circuit is called a half-adder and is designed to add 2 binary numbers with a carry (C) if the sum (S) is greater than 1.

An example of a logic diagram, the half-adder logic circuit
An example of a logic diagram, the half-adder logic circuit

This logic diagram can be written as the following logic statements:

S = (A OR B) AND (NOT (A AND B))
C = (A AND B)


What is a truth table?

A truth table is a table that lists all the output(s) for every possible combination of input(s) in a logic diagram.

The truth tables for the 3 most common logic gates.

ANDORNOT
INPUT OUTPUT
0 0 0
0 1 0
1 0 0
1 1 1
INPUTOUTPUT000010100111
INPUT OUTPUT
0 0 0
0 1 1
1 0 1
1 1 1
INPUTOUTPUT000011101111
INPUT OUTPUT
0 1
1 0
INPUTOUTPUT0110
INPUTOUTPUT
000
010
100
111
INPUTOUTPUT
000
011
101
111
INPUTOUTPUT
01
10

How is a truth table produced from a logic diagram?

To produce a truth table from a logic diagram you need to work out the outputs for every possible combination of inputs. If a logic diagram has only 2 inputs then there will only be 4 input combinations (00, 01, 10 and 11). If there are 3 inputs then there will be 8 possible combinations and 4 inputs would give 16 combinations. Therefore n inputs gives 2n outputs.

Examples of truth tables produced from logic diagrams

A logic diagram that combines an AND and a NOT gate

A logic diagram showing an OR gate combined with a NOT gate

Logic diagram: O = (NOT A) AND B
INPUT OUTPUT
A B O
0 0 1
0 1 1
1 0 1
1 1 0
INPUTOUTPUTABO001011101110
INPUT OUTPUT
A B O
0 0 1
0 1 0
1 0 0
1 1 0
INPUTOUTPUTABO001010100110
INPUT OUTPUT
A B O
0 0 0
0 1 1
1 0 0
1 1 0
INPUTOUTPUTABO000011100110
INPUTOUTPUT
ABO
001
011
101
110
INPUTOUTPUT
ABO
001
010
100
110
INPUTOUTPUT
ABO
000
011
100
110

The truth table for the half-adder circuit:

INPUTSOUTPUTS
ABDESC
000100
011110
101110
111001
A 14 pin semiconductor chip with a logic gate diagram overlay to show the internal connections

Logic gates are typically formed as integrated circuits on semiconductor chips.

The example shown is a 14 pin chip containing 4 NAND gates.

Extras