EEasy IGCSELabTracker

On a phone the notes, quizzes and tracker work fine. The 3D models and the practice lab are made for a laptop.

Specification points 1.1.1–1.1.6 ·

binary, denary and hexadecimal, conversions, binary addition and overflow, logical shifts and two's complement.

1Why computers use binary

A computer is built from millions of tiny switches (transistors) that have only two states, on and off, written 1 and 0. Data is processed using logic gates and stored in registers, both of which work with these two states.

So any form of data — numbers, text, sound, images, program instructions — must be converted to binary before a computer can process or store it.

2Denary, binary and hexadecimal

Definition

Denary — base 10: digits 0–9; each column is worth 10 × the column to its right.

Binary — base 2: digits 0 and 1; each column is worth 2 × the column to its right.

Hexadecimal (hex) — base 16: digits 0–9 then A = 10, B = 11, C = 12, D = 13, E = 14, F = 15; each column is worth 16 × the column to its right.

Number system Column values (right‑most column first)
Binary (8‑bit) 1 · 2 · 4 · 8 · 16 · 32 · 64 · 128
Binary (next 8 bits, up to 16‑bit) 256 · 512 · 1024 · 2048 · 4096 · 8192 · 16384 · 32768
Hexadecimal 1 · 16 · 256 · 4096

Only positive whole numbers are converted, up to 16 bits (largest 8-bit value 255; largest 16-bit value 65 535).

3Converting between the systems

Binary → denary

Add the column values that contain a 1.

1286432168421
10110101

10110101 = 128 + 32 + 16 + 4 + 1 = 181

Denary → binary

Work from the largest column: if the column value fits into what is left, write 1 and subtract it; otherwise write 0.

181: 128 fits (53 left) → 1; 64 no → 0; 32 fits (21 left) → 1; 16 fits (5 left) → 1; 8 no → 0; 4 fits (1 left) → 1; 2 no → 0; 1 fits → 1. Answer 10110101.

Hexadecimal ↔ binary

One hex digit is exactly 4 bits (a nibble). Split the binary into groups of 4 from the right (pad the left group with 0s), and convert each group on its own using 8 4 2 1.

binary 8 4 2 1 1 0 1 1 8 + 2 + 1 = 11 B 8 4 2 1 0 1 0 1 4 + 1 = 5 5 hex = B5 = 181 (denary) each hex digit ↔ one nibble
Figure 1. Binary ↔ hexadecimal, one nibble per hex digit. For 16 bits use four groups: 2F9A = 0010 1111 1001 1010.

Flip the bits: binary, denary, hex

Loading the interactive…

Hexadecimal ↔ denary

  • Hex → denary: multiply each digit by its column value and add. 3E = (3 × 16) + (14 × 1) = 62.
  • Denary → hex: divide by 16; the whole-number answer is the 16s digit and the remainder is the 1s digit. 200 ÷ 16 = 12 remainder 8 → C8. (Or convert to binary first, then group into nibbles.)

4Why hexadecimal is used

Hex is easier for humans to read, write and remember than binary because it is a shorter representation of binary: each hex digit replaces 4 bits, so there is less chance of error when copying or typing. It converts to and from binary very easily. The computer itself still stores and processes everything in binary.

Where hex is used Example
MAC addresses 00‑1C‑B3‑4F‑25‑FE (48 bits as 12 hex digits)
IPv6 addresses a8fb:7a88:fff0:0fff:3d21:2085:66fb:f0fa
HTML colour codes #FF0000 = red: two hex digits each for red, green, blue
Error codes memory locations shown in hex when a program fails

5Adding binary numbers and overflow

Add column by column from the right, like denary: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 carry 1, 1 + 1 + 1 = 1 carry 1.

Within 8 bits 0 1 0 1 1 0 1 0 0 0 1 1 1 0 1 1 + 1 1 1 1 1 carry 1 0 0 1 0 1 0 1 90 59 carry whenever a column total is 2 or 3 90 + 59 = 149 ✓ 149 Overflow 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 + 1 1 carry 0 0 1 0 1 1 0 0 200 100 1 9th bit cannot be stored → overflow stored: 00101100 = 44, not 300 44 ✗
Figure 2. Binary addition with carries (left) and an overflow (right).

Add two bytes, carry by carry

Loading the interactive…

Definition

Overflow error — occurs when the result of a calculation is too large to be stored in the number of bits available. A device has a predefined limit it can represent or store (for example 8-bit or 16-bit); overflow occurs when a value outside this limit should be returned.

In an 8-bit register the largest value is 255, so any sum greater than 255 causes an overflow: a 9th bit is generated, it cannot be stored and is lost, and the stored result is wrong.

6Logical binary shifts

A logical shift moves every bit in the register left or right by a given number of places.

  • Bits shifted off the end of the register are lost.
  • Zeros are shifted in at the opposite end.
  • Each left shift multiplies the number by 2; each right shift divides it by 2. So a shift of n places multiplies or divides by 2ⁿ (2 places = × or ÷ 4; 3 places = × or ÷ 8).
Logical left shift, 2 places 0 0 0 1 0 1 1 0 0 1 0 1 1 0 0 0 lost 0s in 22 88 left 2 → × 4 Logical right shift, 2 places 1 0 1 1 0 1 0 0 0 0 1 0 1 1 0 1 lost 0s in 180 45 right 2 → ÷ 4
Figure 3. Logical left shift and logical right shift, two places each.

Shift the register

Loading the interactive…

A left shift loses the most significant bit(s) (left); a right shift loses the least significant bit(s) (right). If a lost bit is a 1, the result is no longer correct:

  • 01100000 (96) shifted left 2 → 10000000 (128), not 384 — the answer is too big for 8 bits.
  • 00010111 (23) shifted right 1 → 00001011 (11), not 11.5 — the remainder is lost.

7Two's complement

Two's complement lets an 8-bit register hold positive and negative integers. The left-most column is worth −128; all other columns are unchanged.

−1286432168421
01101110
  • Left-most bit 0 → positive; 1 → negative.
  • Range: −128 (10000000) to +127 (01111111).
  • A positive number is written exactly as in ordinary binary, with 0 in the −128 column (above: 01101110 = +110).

Two's complement → denary

Add the column values, using −128 for the left-most bit. 11100100 = −128 + 64 + 32 + 4 = −28.

Negative denary → two's complement

Write the positive number in 8-bit binary, invert every bit (0 ↔ 1), then add 1.

−128 64 32 16 8 4 2 1 1 write +67 in binary 0 1 0 0 0 0 1 1 = +67 2 invert every bit 1 0 1 1 1 1 0 0 3 add 1 1 0 1 1 1 1 0 1 = −67 +1 Check: −128 + 32 + 16 + 8 + 4 + 1 = −67
Figure 4. Finding −67 in 8-bit two's complement.

Make a negative number in two's complement

Loading the interactive…

The same method converts a negative binary value: −101101 → pad to 00101101 → invert 11010010 → add 1 → 11010011.

Traps
Wrong Right
Grouping binary into nibbles from the left Group from the right; pad the left group with 0s
Hex digits go up to 16 Hex digits go 0–F, i.e. 0–15
In a shift, empty places are filled with the bit that fell off Empty places are always filled with 0
Two's complement of −n: invert the bits and stop Invert and add 1

Quick check

12 multiple-choice questions. Pick an answer to see whether it is right and why.

  1. Why must all data be converted to binary before a computer can process it?

  2. What is the binary number 01101100 in denary?

  3. What is denary 203 as an 8-bit binary number?

  4. What is the binary number 10101110 in hexadecimal?

  5. What is hexadecimal 4B in denary?

  6. Why do computer scientists use hexadecimal?

  7. What is the 8-bit result of adding 00101101 and 01000111?

  8. Which addition causes an overflow error in an 8-bit register?

  9. The register 00010011 is given a logical left shift of three places. What is the result?

  10. The register 01101010 (106) is given a logical right shift of two places. What denary value does it now hold?

  11. What is the 8-bit two's complement integer 10110101 in denary?

  12. What is −42 as an 8-bit two's complement integer?

Exam-style questions

Write your answer, then show the answer and compare. Nothing here is marked for you: you decide how close you were. What you write is saved in this browser.

Recall

1

State the base of the denary, binary and hexadecimal number systems.

2

What is the largest denary value an 8-bit register can hold?

3

What denary value does the hex digit D represent?

Conversions

4

Convert 10011101 to denary.

5

Convert 214 to 8-bit binary.

6

Convert the 16-bit binary number 0110 1011 1110 0001 to hexadecimal.

7

Convert hex 9C to (a) denary (b) 8-bit binary.

8

Convert 250 to hexadecimal.

Binary arithmetic and shifts

9

Add 01101001 and 00110110. Give the 8-bit answer.

10

Add 10110111 and 01011010 in an 8-bit register. State the stored result and explain what has happened.

11

Perform a logical left shift of two places on 00101101. State the effect on the denary value.

12

Perform a logical right shift of three places on 11010000. State the denary values before and after.

13

00001011 is shifted right two places. Explain why the result is not exactly the original value ÷ 4.

Two's complement

14

Write +93 and −93 as 8-bit two's complement integers.

15

Convert the two's complement integer 11110110 to denary.

16

State the largest and smallest values that can be stored in 8-bit two's complement.

Exam-style

17

Explain why computers use binary to represent data.

2 marks
18

Explain why hexadecimal is used by computer scientists, giving one area where it is used.

3 marks
19

Explain what is meant by an overflow error and why it occurs.

3 marks

How well do you know this?

Rate each specification point. It is saved to your tracker as a new revision round.

All points:
  • 1.1.1Understand how and why computers use binary to represent all forms of data
  • 1.1.2
    • Understand the denary, binary and hexadecimal number systems
    • Convert between
    • positive denary and positive binary (ii) positive denary and positive hexadecimal (iii) positive hexadecimal and positive binary
  • 1.1.3Understand how and why hexadecimal is used as a beneficial method of data representation
  • 1.1.4
    • Add two positive 8-bit binary integers
    • Understand the concept of overflow and why it occurs in binary addition
  • 1.1.5Perform a logical binary shift on a positive 8-bit binary integer and understand the effect this has on the positive binary integer
  • 1.1.6Use the two’s complement number system to represent positive and negative 8-bit binary integers

Settings

Your subjects

Untick the subjects you don't take. They leave the menu, the home page and the tracker. Your ratings are kept, so you can bring a subject back at any time.

Page style

Colours