Show understanding of different number systems

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science 9618 – 1.1 Data Representation

1.1 Data Representation – Understanding Number Systems

Why Different Number Systems?

Computers operate using binary (base‑2) because electronic circuits have two stable states: off (0) and on (1). Humans, however, find decimal (base‑10) more intuitive. Octal (base‑8) and hexadecimal (base‑16) are convenient shorthand notations for binary data.

Common Number Systems

  • Binary (Base‑2): Digits 0, 1
  • Octal (Base‑8): Digits 0–7
  • Decimal (Base‑10): Digits 0–9
  • Hexadecimal (Base‑16): Digits 0–9 and A–F (where A=10, …, F=15)

Positional \cdot alue

In any base‑\$b\$ system, the value of a digit \$di\$ at position \$i\$ (counting from right, starting at 0) is \$di \times b^{i}\$.

Example for binary number \$1011_2\$:

\$10112 = 1\times2^{3}+0\times2^{2}+1\times2^{1}+1\times2^{0}=8+0+2+1=11{10}\$

Conversion Between Number Systems

Binary ↔ Decimal

  1. To convert binary to decimal, multiply each bit by the corresponding power of 2 and sum.
  2. To convert decimal to binary, repeatedly divide by 2, recording remainders.

Binary ↔ Octal

Group binary digits in sets of three, starting from the right. Replace each group with its octal equivalent.

Binary ↔ Hexadecimal

Group binary digits in sets of four, starting from the right. Replace each group with its hexadecimal equivalent.

Conversion Tables

Binary (4‑bit)OctalDecimalHexadecimal
0000000
0001011
0010022
0011033
0100044
0101055
0110066
0111077
1000188
1001199
1010110A
1011111B
1100112C
1101113D
1110114E
1111115F

Signed Number Representation

Two’s complement is the standard method for representing signed integers in binary.

  1. Determine the binary magnitude of the absolute value.
  2. Invert all bits (one’s complement).
  3. Add 1 to the result.

Example: Represent \$-13_{10}\$ in an 8‑bit two’s complement system.

\$13{10}=000011012\$

\$\text{One's complement}=11110010_2\$

\$\text{Add 1}=11110011_2\$

Thus \$-13{10}=111100112\$.

Floating‑Point Representation (Brief)

IEEE 754 single‑precision format uses 32 bits:

  • 1 bit for sign (S)
  • 8 bits for exponent (E) with a bias of 127
  • 23 bits for mantissa (M)

The value is \$(-1)^{S}\times1.M\times2^{(E-127)}\$.

Suggested diagram: Flowchart showing conversion steps between binary, octal, decimal, and hexadecimal.

Key Points to Remember

  • All number systems are positional; the base determines the weight of each position.
  • Binary ↔ Octal and Binary ↔ Hexadecimal conversions are fast because 8 = \$2^{3}\$ and 16 = \$2^{4}\$.
  • Two’s complement allows a single arithmetic circuit for addition and subtraction.
  • Understanding these representations is essential for interpreting low‑level data, debugging, and designing algorithms.