Data Representation

Data Representation

Number systems: binary, denary and hexadecimal

Number Systems Paper 1 19 min read

On this page
  1. In this note
  2. What you should already know
  3. Why computers use binary
  4. Denary, binary and hexadecimal
  5. Binary to denary
  6. Denary to binary
  7. How big a number can a register hold?
  8. Converting with hexadecimal
  9. Summary
  10. Ways they test it
  11. What the examiner looks for
  12. Past-paper questions, solved
  13. Common mistakes
  14. Practice
  15. Can I do this?
  16. Quiz

In this note

Syllabus 1.1 Number systems
  • 1.1.1Explain how and why computers use binary to represent all data.
  • 1.1.2Understand the denary, binary and hexadecimal number systems.
  • 1.1.2Convert positive whole numbers between denary, binary and hexadecimal, in every direction (up to 16 bits).
  • 1.1.2Work out the largest number a register can hold and the fewest bits a number needs.

Next: Hexadecimal uses and binary addition.

Part 1Learn the topic

The notes: every idea from the start, with our own examples.

What you should already know

Place value in denary

In 365 the 3 is worth 300, the 6 is worth 60 and the 5 is worth 5. Each column is worth ten times the column to its right: 1, 10, 100, 1000.

Quick check: what is the 4 worth in 4 072?

4000 (the thousands column).

Powers of 2

Keep doubling from 1: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 … You will use these in every question on this page, so learn them up to 128 (and 2048, 4096 … for 12 and 16 bits).

Quick check: what comes after 128?

256.

Why computers use binary

Inside a computer, data is processed by millions of tiny electronic switches called transistors, wired together into logic gates. A switch can only be in one of two states: on or off. So a computer can only hold two values, which we write as 1 and 0.

That is why every kind of data has to be turned into binary before a computer can process or store it: numbers, text, images, sound, and the program instructions themselves. Binary values are held in registers (small stores inside the processor) and in memory.

Binary is a base 2 number system: it uses only the two digits 0 and 1. One binary digit is called a bit.
Why binary, in one sentence: computers are made of switches / logic gates that have only two states, so they can only process 1s and 0s.

Denary, binary and hexadecimal

A number system's base is how many different digits it uses. Every system works with place value: each column is worth the base times the column to its right.

SystemBaseDigitsColumn values (right to left)Who uses it
Denary100 to 91, 10, 100, 1000 …people, every day
Binary20 and 11, 2, 4, 8, 16, 32, 64, 128 …the computer itself
Hexadecimal (hex)160 to 9, then A to F1, 16, 256, 4096programmers: a short way to write binary

In hex the letters stand for the numbers 10 to 15, because one column must hold a single digit:

Denary0123456789101112131415
Hex0123456789ABCDEF
Binary0000000100100011010001010110011110001001101010111100110111101111
You do not need to memorise the binary row: in the exam, count up in four columns 8 4 2 1. Two worth knowing by heart: A = 10 = 1010 and F = 15 = 1111.

Binary to denary

An 8-bit binary number has these column (place) values. A 1 means "include this column", a 0 means "leave it out":

1001 1100 = 128 + 16 + 8 + 4 = 156
1286432168421
Binary10011100

General methodBinary to denary

  1. Write the place values over the bits: 1 under the rightmost bit, then 2, 4, 8 … going left.
  2. Add the place values that have a 1 under them.
  3. Check: the answer is odd only if the last bit is 1, and 8 bits can never give more than 255.

Example Convert 0010 1101 to denary.

Add the place values of the 1s.

  1. 32 + 8 + 4 + 1

Answer 45

Try it yourself

1
Convert 0101 0101 to denary.
Show working
  1. 64 + 16 + 4 + 1 = 85

Answer 85

2
Convert 1111 1111 to denary.
Show working
  1. 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 (the largest 8-bit number)

Answer 255

3
Convert 1100 1000 to denary.
Show working
  1. 128 + 64 + 8 = 200

Answer 200

Denary to binary

Two methods give the same answer. Use whichever you find quicker; the mark scheme accepts both.

Method A: subtract place values

General methodTake away the biggest place value that fits

  1. Write the place values 128 64 32 16 8 4 2 1.
  2. Start at 128. Does it fit into what is left? Yes: write 1 and subtract it. No: write 0.
  3. Move to the next place value and repeat until you reach 1.
  4. Read the bits from left to right.

Example Convert 156 to 8-bit binary.

Take away the biggest place value that fits, each time.

  1. 128 fits: 1, and 156 − 128 = 28 left
  2. 64? no: 0. 32? no: 0. 16 fits: 1, and 28 − 16 = 12 left
  3. 8 fits: 1, 4 left. 4 fits: 1, 0 left. 2? no: 0. 1? no: 0

Answer 1001 1100

Method B: divide by 2

General methodKeep dividing by 2 and read the remainders upwards

  1. Divide the number by 2. Write down the answer and the remainder (0 or 1).
  2. Divide the answer by 2 again. Keep going until the answer is 0.
  3. The first remainder is the rightmost bit: read the remainders from the bottom up.
  4. Add 0s on the left to make 8 bits (or the number of bits asked for).
DivideAnswerRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Reading upwards: 1001 1100.

If the question says 8-bit, the answer must have exactly 8 bits: 14 is 0000 1110, not 1110. Leading zeros never change the value, but they show the size of the register.

Try it yourself

1
Convert 50 to 8-bit binary.
Show working
  1. 32 + 16 + 2 = 50

Answer 0011 0010

2
Convert 102 to 8-bit binary.
Show working
  1. 64 + 32 + 4 + 2 = 102

Answer 0110 0110

3
Convert 221 to 8-bit binary.
Show working
  1. 128 + 64 + 16 + 8 + 4 + 1 = 221

Answer 1101 1101

How big a number can a register hold?

A register has a fixed number of bits. With all bits set to 1 you get the largest number it can hold.

BitsSmallestLargestHow many different values
4 (a nibble)015 (1111)16
8 (a byte)0255 (1111 1111)256
1204095 (FFF in hex)4096
16065 535 (FFFF in hex)65 536

Largest value

n bits hold up to 2ⁿ − 1: 8 bits → 2⁸ − 1 = 255.

Fewest bits for a number

Keep doubling until the place value is bigger than the number, then count the place values you used. 301: 256 is not bigger, 512 is → 1, 2, 4 … 256 is 9 bits.

Fewest bits for a hex number

Each hex digit is exactly 4 bits, so count the digits × 4: A4D has 3 digits → 12 bits.

Try it yourself

1
What is the largest denary number an 8-bit register can store?
Show answer

Answer 255

2
What is the least number of bits needed to store the denary number 200?
Show working
  1. 128 ≤ 200 < 256, and 256 = 2⁸, so 8 bits

Answer 8

3
What is the least number of bits needed to store the hexadecimal number 3F2?
Show working
  1. 3 hex digits × 4 bits = 12

Answer 12

Converting with hexadecimal

The key fact: one hex digit is exactly 4 bits (a nibble), because 16 = 2⁴. So binary and hex convert by grouping in fours; no adding up of big numbers is needed.

Binary to hex

General methodBinary to hexadecimal

  1. Split the bits into groups of 4 starting from the right. If the left group is short, add 0s in front.
  2. Work out each group with the place values 8 4 2 1 (10 to 15 become A to F).
  3. Write the hex digits in the same order.
1011 0011 1010 → B 3 A. Each group of four is worked out on its own.
842184218421
Binary101100111010
HexB3A

Hex to binary

General methodHexadecimal to binary

  1. Turn every hex digit into exactly 4 bits, zeros included.
  2. Write the groups side by side.

Example Convert A04 to binary.

Four bits for every digit, even the 0.

  1. A = 1010
  2. 0 = 0000
  3. 4 = 0100

Answer 1010 0000 0100

Dropping a 0000 group is the classic mistake: A04 is 1010 0000 0100 (12 bits), not 1010 0100.

Hex to denary

Method A: hex place values

General methodMultiply by 1, 16, 256

  1. Hex place values from the right are 1, 16, 256 (and 4096).
  2. Multiply each digit (A = 10 … F = 15) by its place value.
  3. Add them up.

Example Convert C0F to denary.

Multiply each digit by its place value.

  1. C = 12 in the 256s: 12 × 256 = 3072
  2. 0 in the 16s: 0
  3. F = 15 in the 1s: 15

Answer 3072 + 0 + 15 = 3087

Method B: through binary

General methodGo through binary

  1. Turn each hex digit into 4 bits.
  2. Convert the binary to denary by adding place values.

Example Convert F0 to denary.

Through binary.

  1. F0 = 1111 0000
  2. 128 + 64 + 32 + 16

Answer 240

F0 is not "150" (writing 15 and 0 side by side). Every digit must be multiplied by its place value: 15 × 16 + 0 = 240.

Denary to hex

Method A: through binary (safest)

General methodGo through binary

  1. Convert the denary number to binary.
  2. Group the bits in fours from the right.
  3. Turn each group into one hex digit.

Example Convert 251 to hex.

Binary first, then group in fours.

  1. 251 = 1111 1011
  2. 1111 = F, 1011 = B

Answer FB

Method B: divide by 16

General methodDivide by 16 and use the remainders

  1. Divide by 16. The remainder (0 to 15) is the rightmost hex digit.
  2. Divide the answer by 16 again; the remainder is the next digit to the left.
  3. Stop when the answer is 0. Read the remainders from the bottom up.

Example Convert 301 to hex.

Divide by 16, keep the remainders.

  1. 301 ÷ 16 = 18 remainder 13 → D
  2. 18 ÷ 16 = 1 remainder 2 → 2
  3. 1 ÷ 16 = 0 remainder 1 → 1

Answer 12D

Try it yourself

1
Convert 1001 0011 to hex.
Show working
  1. 1001 = 9, 0011 = 3

Answer 93

2
Convert 2D to binary.
Show working
  1. 2 = 0010, D = 1101

Answer 0010 1101

3
Convert 236 to hex.
Show working
  1. 236 = 1110 1100
  2. 1110 = E, 1100 = C

Answer EC

4
Convert 1A to denary.
Show working
  1. 1 × 16 + 10 = 26

Answer 26

Summary

  • Computers use binary because they are made of switches / logic gates with only two states (1 and 0). All data is converted to binary.
  • Denary is base 10, binary is base 2 (0, 1), hexadecimal is base 16 (0-9, A-F).
  • 8-bit place values: 128 64 32 16 8 4 2 1. Binary to denary: add the place values of the 1s.
  • Denary to binary: subtract the biggest place value that fits (or divide by 2, read remainders upwards). Give the number of bits asked for.
  • One hex digit = 4 bits. Binary ↔ hex: group in fours from the right.
  • Hex to denary: digit × 16 + digit (× 256 for a third digit). Denary to hex: go through binary, or divide by 16.
  • n bits hold 0 to 2ⁿ − 1 (8 bits: 0-255). Fewest bits: first power of 2 bigger than the number; hex: digits × 4.

If you see …

  • "Convert … to 8-bit binary"exactly 8 bits, with leading zeros
  • "least number of bits"first power of 2 bigger than the number (hex: 4 per digit)
  • a hex digit 0 in the middlewrite it as 0000
Part 2How it is examined

Question types, what the examiner gives marks for, and real past-paper questions solved.

Ways they test it

Type 1 Convert three numbers

"Convert these three denary numbers to 8-bit binary numbers: 50, 102, 221" [3]. Also binary → hex, hex → binary, denary → hex, often as a table to fill in.

Spot it a list of numbers and a working space.

  1. One mark per number, all or nothing, so check each one.
  2. Binary answers: the number of bits asked for.
  3. Hex answers: "one mark per correct character in the correct order" for longer conversions.

Type 2 Explain the system

"Explain what is meant by a binary number system" [2]

Spot it "what is meant by" / "explain".

  1. It is base 2.
  2. It uses only two values, 1 and 0.

Type 3 Why binary

"Explain why data input into the machine needs to be converted to binary" [2]

Spot it "why" + "binary".

  1. The computer contains logic gates / switches …
  2. … that only process two states / 1 and 0.

Type 4 Size of a register

"State the highest denary number in an 8-bit register" [1], "Calculate the least number of bits to store 301" [1]

Spot it "highest", "least number of bits".

  1. 2ⁿ − 1 for the highest.
  2. First power of 2 bigger than the number for the bits.

Type 5 Similarities and differences

"Give one similarity and two differences between hexadecimal and binary" [3]

Spot it two systems compared.

  1. Similarity: both are number systems (both can represent the same values).
  2. Differences: base 2 vs base 16; binary uses only 0 and 1, hex uses 0-9 and A-F; hex is shorter.

What the examiner looks for

"Explain why computers use binary" [2]

Marking points (one mark each, up to the marks shown)

  • Computers contain logic gates / switches …
  • … that only have two states // only process the values 1 and 0.

Keywords logic gates switches two states 1 and 0

Too vague "computers understand binary"; "binary is easier for computers"

"Explain what is meant by a binary number system" [2]

Marking points (one mark each, up to the marks shown)

  • It has a base of 2.
  • It only uses two values …
  • … that are 1 and 0.

Keywords base 2 1 and 0

Writing an 8-bit binary answer

2210/13/O/N/23 Q2Paper 1 · Computer systems3 marks
Convert the denary number 14 to binary.
Credited
  • 0000 1110
  • 1110 (the scheme wrote (0000)1110: leading zeros optional when no number of bits is set)
Not credited
  • 111 (a bit missing)
  • 0111 0000 (written backwards)
Why

When the question says 8-bit, write all 8 bits; then a missing leading 0 can never cost you the mark.

From: 2210/13/O/N/23 Q2(b) mark scheme

Past-paper questions, solved

2210/13/O/N/23 Q2Paper 1 · Computer systems8 marksFull size
Explain binary; convert 14, 59, 234 to binary and 9, 26, 65 to hex

How to start Part (a) is two facts about binary (base, two values). For (b) and (c) use the place-value table; go through binary for the hex.

Show a full-mark answer and the mark scheme

(a) A binary number system has a base of 2. It uses only two values, 1 and 0.

(b) 14 = 0000 1110 · 59 = 0011 1011 · 234 = 1110 1010

(c) 9 = 9 · 26 = 0001 1010 = 1A · 65 = 0100 0001 = 41

PartAnswer / workingMarksGuidance
2(a)Any two from: it has a base of 2 · it only uses two values · … that are 1 and 0B2
2(b)(0000)1110 · (00)111011 · 11101010B3one mark each
2(c)9 · 1A · 41B3one mark each
Total: 8 marks
0478/11/O/N/23 Q2Paper 1 · Computer systems8 marksFull size
Car park: two 8-bit registers hold the dollars and cents; ticket number in hex

How to start Each register is a separate 8-bit number: convert register 1 for the dollars and register 2 for the cents. For (c) group the 16 bits in fours.

Show a full-mark answer and the mark scheme

(a) 0001 0001 = 16 + 1 = 17 and 0100 0110 = 64 + 4 + 2 = 70, so $17.70.

(b) 14 = 0000 1110 and 98 = 64 + 32 + 2 = 0110 0010.

(c) 1010 | 0000 | 0011 | 1101 = A 0 3 D, so A03D.

PartAnswer / workingMarksGuidance
2(a)17 · 70 (correct fee $17.70)B2one mark for each part, in the correct order
2(b)Register 1: 00001110 · Register 2: 01100010B2
2(c)A · 0 · 3 · DB4one mark per correct character in the correct order
Total: 8 marks

Examiner tip A whole 16-bit number given at once? Split it into nibbles first and write the four groups down before converting.

0478/13/M/J/23 Q1Paper 1 · Computer systems5 marksFull size
10101110 to denary and hex; least bits for 301 and for A4D

How to start Same number twice: add the place values for denary, group in fours for hex. For the least number of bits, find the first power of 2 above the number.

Show a full-mark answer and the mark scheme

(a) 128 + 32 + 8 + 4 + 2 = 174

(b) 1010 = A, 1110 = E → AE

(e) 256 < 301 < 512 = 2⁹ → 9 bits

(f) 3 hex digits × 4 bits = 12 bits

PartAnswer / workingMarksGuidance
1(a)174B1
1(b)A · EB2one mark per character in the correct order
1(e)9B1
1(f)12B1
Total: 5 marks

Common mistakes

  • ✗ 14 → 1110 when 8 bits are asked for✓ 0000 1110Give the number of bits the question asks for.
  • ✗ A04 → 1010 0100✓ 1010 0000 0100Every hex digit is 4 bits, the 0 too.
  • ✗ F0 → 150✓ F0 = 15 × 16 = 240Multiply each hex digit by its place value.
  • ✗ Grouping bits from the left: 101101 → 1011 01✓ 0010 1101 → 2DAlways group from the right and pad the left group.
  • ✗ "Computers use binary because it is easy"✓ "made of switches / logic gates with two states, 1 and 0"Name the hardware reason.

Practice

Practice: easy, medium, hard

Easy

1
Convert 0110 1001 to denary.
Show working
  1. 64 + 32 + 8 + 1

Answer 105

2
Convert 77 to 8-bit binary.
Show working
  1. 64 + 8 + 4 + 1

Answer 0100 1101

3
Convert 1100 0111 to hex.
Show answer

Answer C7

4
What is the base of hexadecimal?
Show answer

Answer 16

Medium

1
Convert B9 to denary.
Show working
  1. 11 × 16 + 9 = 176 + 9

Answer 185

2
Convert 175 to hex.
Show working
  1. 175 = 1010 1111
  2. A F

Answer AF

3
Convert 3C to 8-bit binary.
Show answer

Answer 0011 1100

4
What is the least number of bits needed to store 1000?
Show working
  1. 512 < 1000 < 1024 = 2¹⁰

Answer 10

Hard

1
Convert 5E3 to binary.
Show answer

Answer 0101 1110 0011

2
Convert 1000 0000 1111 to denary.
Show working
  1. 2048 + 8 + 4 + 2 + 1

Answer 2063

3
Convert 700 to hex.
Show working
  1. 700 ÷ 16 = 43 r 12 (C)
  2. 43 ÷ 16 = 2 r 11 (B)
  3. 2 ÷ 16 = 0 r 2

Answer 2BC

PartAnswer / workingMarksGuidance
2BCB2one mark for two correct characters, two marks for all three in order
Total: 2 marks
4
A register is 12 bits. Give the largest number it can store in denary and in hex.
Show working
  1. 12 bits all 1 = 2¹² − 1 = 4095
  2. three groups of 1111 = FFF

Answer 4095 · FFF

Can I do this?

Anything unticked: revise that section first. All ticked: take the quiz.

Quiz

The multiple-choice and guided questions need JavaScript. The concept checks and exam practice below work without it.

Your progress on this note is saved when JavaScript is on.

⬇️ Download this chapter as a PDF: Full notes