Numbers

KS3 Computer Science

11-14 Years Old

48 modules covering EVERY Computer Science topic needed for KS3 level.

GCSE Computer Science

14-16 Years Old

45 modules covering EVERY Computer Science topic needed for GCSE level.

A-Level Computer Science

16-18 Years Old

66 modules covering EVERY Computer Science topic needed for A-Level.

GCSE Binary System (14-16 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

A-Level Hexadecimal Resources (16-18 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

Candidates should be able to:

  • convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa
  • add two 8-bit binary integers and explain overflow errors which may occur
  • convert positive denary whole numbers (0-255) into 2-digit hexadecimal numbers and vice versa
  • convert between binary and hexadecimal equivalents of the same number
  • explain the use of hexadecimal numbers to represent binary numbers.

What is the difference between binary and denary (decimal) numbers?

Denary numbers

In denary (decimal) there are 10 digits (0-9). The least significant digit represents the number of 1’s, the next significant digit the number of 10’s and the next the number of 100’s etc. This can be shown in a table, where each column to the left of the least significant digit represents increasing powers of 10 (i.e. 102, 103, 104 etc.). Consider the denary number 6207:

The equivalent denary number for
each column
  
1000100101The calculationThe denary number
62076000+200+76207

The denary number 6207 can therefore be represented as:

(1000 x 6) + (100 x 2) + (10 x 0) + (1 x 7) = 6207

Binary numbers

In binary, there are only 2 digits (0-1). As with denary, the least significant digit represents the number of 1’s but the next significant digit now represents the number of 2’s and the next the number of 4’s etc. This can be shown in a table, where each column to the left of the least significant digit represents increasing powers of 2 (i.e. 22, 23, 24 etc.). Consider the 8-bit binary number 10011011:

The equivalent denary number for
each column
  
1286432168421The calculationThe denary equivalent
10011011128+16+8+2+1155

The binary number 10011011 can therefore be represented as

(128 x 1) + (64 x 0) + (32 x 0) + (16 x 1) + (8 x 1) + (4 x 0) + (2 x 1) + (1 x 1) = 155


Number conversion between denary (0-255) and 8-bit binary

A binary to denary game
A binary to denary game

To convert from 8-bit binary to denary

To do this you add together the equivalent denary numbers for each non-zero bit. In the example above the 8-bit binary number 10011011 converts into denary 155 as follows.

(128 x 1) + (16 x 1) + (8 x 1) + (2 x 1) + (1 x 1) = 155

To convert from denary to 8-bit binary

A denary to binary game
A denary to binary game

The largest denary number that can be converted into 8-bit binary is 255 (binary 11111111). To convert a denary number between 0 and 255 follow the 8 steps below (if a condition is not true then the bit being checked should be set to 0):

Denary to 8-bit binary conversion
Denary to 8-bit binary conversion
  1. If the number is >= 128 then:
    1. set bit 8 to 1
    2. take away 128
  2. If the number is now >=64 then:
    1. set bit 7 to 1
    2. take away 64
  3. If the number is now >=32 then:
    1. set bit 6 to 1
    2. take away 32
  4. If the number is now >=16 then:
    1. set bit 5 to 1
    2. take away 16
  5. If the number is now >=8 then:
    1. set bit 4 to 1
    2. take away 8
  6. If the number is now >=4 then:
    1. set bit 3 to 1
    2. take away 4
  7. If the number is now >=2 then:
    1. set bit 2 to 1
    2. take away 2
  8. If the number is now 1 then:
    1. set bit 1 to 1

Number conversion between denary (0-255) and 2-digit hexadecimal

Hexadecimal numbers (number base 16) have 16 different digits, as shown in the table below.

DenaryHexadecimal
00
11
22
33
44
55
66
77
88
99
10A
11B
12C
13D
14E
15F

To convert from 2-digit hexadecimal to denary:

Example: To convert hexadecimal AF onto denary 175:

  • Convert the least significant digit directly using the table above. (F=15)
  • Convert the second digit using the table and then multiply it by 16. (A = 10 so 10 x 16 = 160)
  • Add the 2 numbers together. (15 + 160 = 175)

To convert denary into 2-digit hexadecimal:

Example: To convert denary 175 into hexadecimal AF

  • Divide the denary number by 16 to get the quotient and the remainder. (175 / 16 = 10 remainder 15)
  • To get the least significant digit, use the table to convert the remainder directly into hexadecimal. (15 = F)
  • To get the next significant digit, use the table to convert the quotient directly into hexadecimal. (10 = A)

Number conversion between 8-bit binary and 2-digit hexadecimal

This can be done quite easily because the first 4 bits of the 8-bit binary number corresponding to the first digit of the hexadecimal number and the last 4 bits correspond to the least significant digit.

For example, binary 11111001 would be equivalent to hexadecimal F9.

BinaryHexadecimal
00000
00011
00102
00113
01004
01015
01106
01117
10008
10019
1010A
1011B
1100C
1101D
1110E
1111F

How can two 8-bit binary numbers be added together?

Adding binary numbers is a similar process to adding denary numbers.

Numbers: An example of binary addition
An example of binary addition

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 10 (0 carry 1)

1 + 1 + carry = 11 (1 carry 1)

In denary, if the digits in the first column (1’s) are added and the sum is greater than 9 then the next column is used (10’s). The least significant digit in the answer stays in the column as part of the total sum and the next significant digit is carried into the next column. (i.e. 8 + 9 = 17 so the 1 is carried into the next column where it represents a 10)

In binary, if the digits in the first column (1’s) are added and the sum is greater than 1 then the next column is used (2’s). As in denary, the least significant digit in the answer stays in the column as part of the total sum and the next significant digit is carried into the next column. (i.e. 1 + 1 = 10 so the 0 stays in the first column and the 1 is carried into the next column where it represents a 2)

Further examples of binary addition:

Binary sumStep-by-step SUMCARRY
  101
+101
—–
1010
Column 1 (the 1’s column): 1 + 1 =
Column 2
(the 2’s column): 0 + 0 + 1 =
Column 3
(the 4’s column): 1 + 1 =
Column 4
(the 8’s column): 0 + 0 + 1 =
0
1
0
1
1
0
1
0
  101
+11
—–
1000
Column 1 (the 1’s column): 1 + 1 =
Column 2
(the 2’s column): 0 + 1 + 1 =
Column 3
(the 4’s column): 1 + 0 + 1 =
Column 4
(the 8’s column): 0 + 0 + 1 =
0
0
0
1
1
1
1
0

What are overflow errors in 8-bit numbers?

An overflow error is an error that occurs when a computer cannot store the result of a calculation in the memory space allocated for the task.

For example, if a computer was only allocated 8 bits to store a number then the largest number possible would be 11111111 (denary 255). If the result of a calculation is a number greater than 1111111 then there would be no bits available to store the final carry and an overflow error would occur.

No overflow error, an 8-bit binary number can store the final carryAn overflow error, there are not enough bits in an 8-bit number to store the final carry
1001001
+1101110
———
10110111
11001001
+11101110
———-
110110111

Why are 2-digit hexadecimal numbers often used to represent 8-bit binary numbers?

When displayed on a screen or printed out, hexadecimal numbers take up considerably less space than binary numbers. Because of this, they are often used to represent 8-bit binary numbers in computing.

Numbers Image 1

This is because a 2-digit hexadecimal number in the range 00 to FF can conveniently represent 1 byte (8-bits) of computer memory in the range 00000000 to 11111111.

Additionally, each digit of the hexadecimal number corresponds to half of the equivalent binary number (a nibble) making conversion easier (i.e. hexadecimal F9 corresponds to binary 11111001).

An example of their use is in a memory dump (a display of the contents of an area of computer memory) such as the one shown above.


A Denary/Binary/Hexadecimal conversion calculator

Number formatConversion
Decimal (0-255):
Binary (00000000 – 11111111):
Hexadecimal (0-FF):

Further Readings: