# Number bases

> CIE A-Level Computer Science · 9618
> Source: https://www.owlsprep.com/study/cie-9618-u1-number-bases/

This module covers place value notation for decimal, binary, and hexadecimal number bases. You will learn how to convert between any pair of these bases for both whole and fractional numbers, a core foundational skill for all computer science topics.

**Prerequisites:** Basic integer and fractional arithmetic

## Learning objectives

- Convert between decimal, binary and hexadecimal number bases for whole and fractional numbers
- Explain positional place value notation for different number bases
- Apply efficient conversion methods for binary-hexadecimal translation
- Solve common conversion problems as required in CIE 9618 examinations

## Place Value Notation

**Positional Number Base** — A system of representing numbers where each digit's value is determined by both the digit itself and its position relative to the radix (decimal) point.

*Example:* Base 10 uses 10 digits (0-9), base 2 uses 2 digits (0-1)

For any base $b$, the rightmost digit before the radix point is the $b^0$ (units) place. Moving left, the exponent increases by 1 for each position. Moving right after the radix point, the exponent decreases by 1 for each position.

$$\text{Value} = \sum_{i=0}^{n} d_i \times b^i + \sum_{j=1}^{m} f_j \times b^{-j}$$

**Worked example:** Calculate the decimal value of $1011.1_2$

1. Map each digit to its place value:
2. $$(1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) + (1 \times 2^{-1})$$
3. Calculate each term: $8 + 0 + 2 + 1 + 0.5$
4. Sum all terms to get the final result: $11.5$

## Converting Whole Decimal Numbers to Other Bases

To convert a whole decimal number to base $b$, use the repeated division method: repeatedly divide the number by $b$, collect each remainder, then read the remainders from last to first to get the converted number.

**Worked example:** Convert 123 decimal to binary

1. Repeatedly divide by 2 and collect remainders:
2. 120 ÷ 2 = 61 rem 1; 61 ÷ 2 = 30 rem 1; 30 ÷ 2 = 15 rem 0; 15 ÷ 2 = 7 rem 1; 7 ÷ 2 = 3 rem 1; 3 ÷ 2 = 1 rem 1; 1 ÷ 2 = 0 rem 1
3. Read remainders from last to first: $1111011_2$

**Check your understanding**

Test your understanding:

1. What is 47 decimal in hexadecimal?

   - 2B
   - 1F
   - 31
   - 2F

   *Why:* 47 ÷ 16 = 2 remainder 15. 15 is represented as F, so the result is 2F, and 2 × 16 + 15 = 47.

## Converting Between Binary and Hexadecimal

Because $16 = 2^4$, there is a direct 1:1 mapping between hexadecimal digits and 4-bit binary groups (called nibbles). This makes conversion between the two bases extremely fast.

**Worked example:** Convert $1101011011_2$ to hexadecimal

1. Add 1 leading zero to make the total number of bits divisible by 4, then group into 4-bit nibbles from the right: $0011\ 0101\ 1011$
2. Map each nibble to its hex equivalent: 0011 = 3, 0101 = 5, 1011 = B
3. Result: $35B_{16}$

**Worked example:** Convert $2A.C_{16}$ to binary

1. Map each hex digit to 4 bits: 2 = 0010, A = 1010, C = 1100
2. Concatenate the bits: $00101010.1100_2$
3. Remove unnecessary leading/trailing zeros to get the simplified result: $101010.11_2$

> **Exam tip:** Always use this direct grouping method instead of converting via decimal, it saves significant time in exams.

## Converting Fractional Decimal Numbers to Other Bases

The whole number part of a mixed number uses the same division method as before. For the fractional part after the radix point, use the repeated multiplication method: repeatedly multiply the fractional part by $b$, collect the whole number part of the result, then read the whole number parts from first to last. Stop when the fractional part becomes 0 or you reach the required precision.

> **warning**
>
> The order of digits for fractional conversion is the reverse of whole number conversion. First obtained digits are the most significant (closest to the radix point).

**Worked example:** Convert 0.625 decimal to binary

1. Start with fractional part 0.625:
2. 0.625 × 2 = 1.25 → whole part = 1, new fractional part = 0.25
3. 0.25 × 2 = 0.5 → whole part = 0, new fractional part = 0.5
4. 0.5 × 2 = 1.0 → whole part = 1, new fractional part = 0 → stop
5. Read whole parts first to last: $0.101_2$

## Common pitfalls

- **Wrong:** Reading remainders in the order they were collected when converting whole decimal to another base
  - Why it fails: The first remainder obtained is the least significant (rightmost) digit, so order must be reversed
  - Correct: Collect remainders from last obtained to first obtained to get the correct number order
- **Wrong:** Reversing the order of digits when converting decimal fractions to another base
  - Why it fails: The first whole part obtained is the most significant (leftmost) digit of the fractional part, so order stays the same
  - Correct: Write whole number parts from first obtained to last obtained for the fractional result
- **Wrong:** Forgetting to add leading/trailing zeros when grouping binary digits for hex conversion
  - Why it fails: If the total number of bits is not a multiple of 4, grouping without padding produces wrong nibble values
  - Correct: Add leading zeros to the whole part and trailing zeros to the fractional part to make every group exactly 4 bits
- **Wrong:** Using positive exponents for digits after the radix point
  - Why it fails: Digits after the point represent fractions of the base, so their place values use negative exponents
  - Correct: Use exponents starting at -1 for the first digit after the radix point
- **Wrong:** Writing 10-15 as two digits in hexadecimal
  - Why it fails: Hexadecimal requires one single digit per place value, so 10-15 must be represented as A-F
  - Correct: Map decimal 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F, one character per digit

## Cheatsheet

| Conversion Type | Method |
| --- | --- |
| Any base → Decimal | Multiply each digit by base^position, sum all terms |
| Whole decimal → base b | Repeated division by b, read remainders last → first |
| Fraction decimal → base b | Repeated multiplication by b, read whole parts first → last |
| Binary → Hexadecimal | Group into 4-bit nibbles, map 1:1 to hex digits |
| Hexadecimal → Binary | Map each hex digit to 4-bit binary, concatenate |

## What's next

Number bases are the foundational building block for all information representation in computer science. Mastering conversion between bases is required to understand almost every subsequent topic, from binary arithmetic and negative number representation to memory addressing and character encoding. This topic is consistently assessed in Paper 1 of CIE 9618, often as the first question to test core foundational skills. Next, you will build on this knowledge to learn how different types of data (signed integers, floating points, text) are represented in binary.

- [Binary representation of integers](https://www.owlsprep.com/study/cie-9618-u1-binary-representation-of-integers/)
- [Binary representation of real numbers](https://www.owlsprep.com/study/cie-9618-u1-binary-representation-of-real-numbers/)
- [Character encoding](https://www.owlsprep.com/study/cie-9618-u1-character-encoding/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/cie-9618-u1-number-bases/
