Show understanding of different number systems

Resources | Subject Notes | Computer Science

Cambridge A-Level Computer Science 9618 - 1.1 Data Representation - Number Systems

Data Representation - Number Systems

Introduction

In computer science, data is represented in binary form. Understanding different number systems is fundamental to comprehending how information is stored and processed within a computer. This section explores the key number systems used in computing: binary, decimal, octal, and hexadecimal.

Binary Number System

The binary number system is the foundation of all digital computers. It uses only two digits: 0 and 1. Each digit in a binary number is called a bit.

The place value of each bit in a binary number is a power of 2, increasing from right to left.

$$1011_2 = (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 8 + 0 + 2 + 1 = 11_{10}$$

Converting from decimal to binary involves repeatedly dividing by 2 and keeping track of the remainders.

For example, converting 25 to binary:

  1. 25 ÷ 2 = 12 remainder 1
  2. 12 ÷ 2 = 6 remainder 0
  3. 6 ÷ 2 = 3 remainder 0
  4. 3 ÷ 2 = 1 remainder 1
  5. 1 ÷ 2 = 0 remainder 1

Reading the remainders in reverse order gives the binary representation: 110012. We can verify this: $11001_2 = (1 \times 2^4) + (1 \times 2^3) + (0 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) = 16 + 8 + 0 + 0 + 1 = 25_{10}$.

Decimal Number System

The decimal number system is the system we use in everyday life. It uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each digit has a place value that is a power of 10.

For example, the number 123 represents: $$1 \times 10^2 + 2 \times 10^1 + 3 \times 10^0 = 100 + 20 + 3 = 123$$.

Octal Number System

The octal number system uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. Each digit has a place value that is a power of 8.

For example, the number 3458 represents: $$3 \times 8^2 + 4 \times 8^1 + 5 \times 8^0 = 3 \times 64 + 4 \times 8 + 5 \times 1 = 192 + 32 + 5 = 229_{10}$$.

Hexadecimal Number System

The hexadecimal number system uses sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. Here, A=10, B=11, C=12, D=13, E=14, and F=15. Each digit has a place value that is a power of 16.

For example, the number 2A316 represents: $$2 \times 16^2 + 10 \times 16^1 + 3 \times 16^0 = 2 \times 256 + 10 \times 16 + 3 \times 1 = 512 + 160 + 3 = 675_{10}$$.

Conversion Table

Number System Base Digits
Binary 2 0, 1
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Conversion between Systems

Converting between these systems is crucial. Binary to decimal can be done by multiplying each bit by its corresponding power of 2 and summing the results. Decimal to binary can be done using repeated division by 2. Hexadecimal to binary and binary to hexadecimal involve grouping bits or powers of 2, respectively.

Why are Number Systems Important?

Different number systems are used for different purposes. Binary is fundamental to computer hardware. Hexadecimal is often used to represent memory addresses and color codes due to its compact representation of binary data. Understanding these systems is essential for working with computer architecture, assembly language, and data encoding.