Understand the denary, binary and hexadecimal number systems

Data Representation – IGCSE Computer Science (0478)

1. Number Systems

The Cambridge syllabus expects you to understand three positional number systems and to convert fluently between them.

1.1 Overview

  • Denary (Decimal) – base 10 – digits 0‑9.
  • Binary – base 2 – digits 0 and 1.
  • Hexadecimal – base 16 – digits 0‑9 and A‑F (A=10 … F=15).

1.2 Positional Value Formulas

For a number with digits \(d_k d_{k-1}\dots d_1 d_0\) (right‑most digit has index 0):

\(N_{b}= \displaystyle\sum_{i=0}^{k} d_i \,b^{\,i}\) where \(b\) is the base (10, 2 or 16).

1.3 Quick‑Reference Table (0 – 15)

DenaryBinary (4‑bit)Hexadecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F

1.4 Converting Between Bases

1.4.1 Denary → Binary (repeated division by 2)
  1. Divide the decimal number by 2.
  2. Record the remainder (0 or 1).
  3. Use the quotient for the next division.
  4. Stop when the quotient is 0.
  5. Read the remainders **upwards** – this is the binary result.

Example: 156₁₀ → binary

DivisionQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Result: 10011100₂

1.4.2 Binary → Denary (positional weights)

Multiply each binary digit by the corresponding power of 2 and sum.

\(101101₂ = 1·2⁵ + 0·2⁴ + 1·2³ + 1·2² + 0·2¹ + 1·2⁰ = 45₁₀\)

1.4.3 Denary → Hexadecimal (repeated division by 16)
  1. Divide by 16.
  2. Record the remainder (0‑9 or A‑F).
  3. Continue with the quotient until it is 0.
  4. Read remainders upwards.

Example: 254₁₀ → hexadecimal

DivisionQuotientRemainder
254 ÷ 161514 (E)
15 ÷ 16015 (F)

Result: FE₁₆

1.4.4 Hexadecimal ↔ Binary
  • Hex → Binary: Replace each hex digit with its 4‑bit binary equivalent. Example: 3B₁₆ = 0011 1011₂ (or simply 11 1011₂).
  • Binary → Hex: Group binary digits into fours (starting from the right) and replace each group with the matching hex digit. Example: 11010111₂ → 1101 0111 → D7₁₆.
1.4.5 Binary Addition (Unsigned)

Use the same carry rules as decimal addition.

Bit position (right‑most first)Bits addedSumCarry
01 + 010
10 + 110
21 + 101
31 + 1 + carry 111

Adding 10110101₂ and 01101110₂ gives 1 0010 0001₂. In an 8‑bit register the leading “1” is discarded, leaving 0010 0001₂ = 33₁₀.

1.4.6 Overflow (Unsigned 8‑bit)
  • Range: 0 – 255 (0000 0000₂ to 1111 1111₂).
  • If addition produces a ninth bit, that bit is lost – this is **overflow**.

Example: 200₁₀ (1100 1000₂) + 100₁₀ (0110 0100₂) = 1 0010 1100₂. Stored result = 0010 1100₂ = 44₁₀ (incorrect for unsigned arithmetic).

1.4.7 Logical Shifts
  • Logical left shift (<< 1): 10110010₂ → 01100100₂ (value doubled modulo 256).
  • Logical right shift (>> 1): 10110010₂ → 01011001₂ (value halved, integer division).
1.4.8 Two’s‑Complement (Signed Numbers)

In an 8‑bit system the most‑significant bit (MSB) is the sign bit (0 = positive, 1 = negative).

  1. Write the absolute value in binary (8‑bit).
  2. Invert every bit (0→1, 1→0).
  3. Add 1 to the inverted result.

Example – Represent –45₁₀:

  1. 45₁₀ = 0010 1101₂
  2. Invert → 1101 0010₂
  3. Add 1 → 1101 0011₂

Thus 1101 0011₂ encodes –45. Adding 45 and –45 yields 0000 0000₂ after discarding the carry‑out, confirming the representation.

1.4.9 Signed Binary Addition (Two’s‑Complement)

Same procedure as unsigned addition; overflow is detected when the carry into the sign bit differs from the carry out of the sign bit.

Example: –60₁₀ + 25₁₀

  • –60 → 1100 0100₂ (two’s‑complement)
  • +25 → 0001 1001₂
  • Sum = 1101 1101₂ → sign bit 1, so result is negative.
  • Invert + 1 → 0010 0011₂ = 35 → final result = –35₁₀.

1.5 Summary of 8‑bit Ranges

RepresentationRange
Unsigned0 – 255
Signed (Two’s‑Complement)–128 – +127

2. Text, Sound and Images

2.1 Text Representation

  • ASCII – 7‑bit code (128 characters). Extended ASCII uses the 8th bit for additional symbols (total 256).
  • Unicode – 16‑bit (or 32‑bit) code point space; allows > 65 000 characters, supporting world languages.
  • UTF‑8 – variable‑length encoding of Unicode; compatible with ASCII for the first 128 characters.
  • UTF‑16 – uses one or two 16‑bit code units; common on Windows.

Why needed? Different languages need more symbols than 128; Unicode provides a universal set, while ASCII remains useful for simple English text and legacy systems.

Example: The character “A”

SystemBinaryHexDecimal
ASCII (7‑bit)0100 0001₂41₁₆65₁₀
Unicode (U+0041)0000 0000 0100 0001₂0041₁₆65₁₀

2.2 Sound Representation

  • Sample rate – number of samples per second (Hz). CD quality = 44 100 Hz.
  • Sample resolution (bit depth) – bits per sample (e.g., 16‑bit → 65 536 amplitude levels).
  • Channels – mono = 1, stereo = 2, surround = > 2.

File‑size formula: size (bits) = duration (s) × sample‑rate (Hz) × bit‑depth × channels

Example: 5 s of 44 100 Hz, 16‑bit, mono audio

\(5 s × 44 100 × 16 × 1 = 3 528 000 bits\)
\(= 441 000 bytes ≈ 430 KB\) (using 1 KB = 1024 bytes)

2.3 Image Representation

  • Resolution – width × height in pixels (e.g., 640 × 480).
  • Colour depth – bits per pixel (bpp). Common depths:
    • 8‑bit → 256 colours (palette).
    • 24‑bit → true colour (16 777 216 colours).
  • Each pixel stores a colour value; the total number of bits = width × height × bpp.

File‑size example: 640 × 480 image at 24‑bit colour

\(640 × 480 × 24 = 7 372 800 bits\)
\(= 921 600 bytes ≈ 900 KB\)


3. Data Storage and Compression

3.1 Units of Storage (binary prefixes)

UnitSymbolEquals
bitb
byteB8 bits
kibibyteKiB1 024 bytes
mebibyteMiB1 024 KiB = 1 048 576 bytes
gibibyteGiB1 024 MiB
tebibyteTiB1 024 GiB

Exam questions often use the binary definitions (KiB, MiB, …).

3.2 File‑size Calculation Using Binary Prefixes

Convert the total number of bits to the required unit, dividing by 8 for bytes and by 1 024 for each higher prefix.

Example: A 3 MiB video file = 3 × 1 048 576 bytes = 3 145 728 bytes = 25 165 824 bits.

3.3 Compression

  • Lossless compression – original data can be perfectly reconstructed (e.g., ZIP, PNG). Useful for text and executable files.
  • Lossy compression – some data is permanently discarded to achieve higher compression ratios (e.g., JPEG, MP3). Acceptable for images, audio, video where a small loss of quality is tolerable.
  • Purpose: reduce storage requirements and speed up transmission.

4. Data Transmission

4.1 Packet Structure (simplified)

FieldTypical Content
HeaderSource/destination addresses, protocol, length, error‑check code
Payload (Data)Actual user data (e.g., part of a file)
TrailerFrame check sequence (CRC) or other end‑of‑packet marker

4.2 USB (Universal Serial Bus)

  • Host‑controlled, point‑to‑point bus.
  • Common speeds: Low‑Speed 1.5 Mbps, Full‑Speed 12 Mbps, High‑Speed 480 Mbps, SuperSpeed 5 Gbps.
  • Uses a tiered‑star topology (host → hub → devices).

4.3 Error Detection & Correction

  • Parity bit – even or odd parity; detects single‑bit errors.
  • Checksum – sum of data bytes; simple but limited.
  • CRC (Cyclic Redundancy Check) – polynomial‑based, detects burst errors.
  • ARQ (Automatic Repeat reQuest) – receiver asks sender to resend corrupted packets.

4.4 Encryption

  • Symmetric encryption – same key for encryption and decryption (e.g., AES). Fast, used for bulk data.
  • Asymmetric encryption – public‑key/private‑key pair (e.g., RSA). Enables secure key exchange and digital signatures.
  • Both protect confidentiality and integrity during transmission.

5. Hardware Fundamentals

5.1 Central Processing Unit (CPU)

  • ALU (Arithmetic‑Logic Unit) – performs calculations and logical operations.
  • Registers – small, fast storage inside the CPU (e.g., accumulator, program counter).
  • Control Unit – interprets instructions and controls data flow.
  • Cache – very fast memory (L1, L2) that stores recently used data/instructions.
  • Multiple cores – allow parallel execution of threads.

5.2 Fetch‑Decode‑Execute Cycle

  1. Fetch the next instruction from memory (address held in the Program Counter).
  2. Decode the instruction in the Instruction Register.
  3. Execute the operation using the ALU or move data between registers and memory.
  4. Update the Program Counter and repeat.

5.3 Memory Hierarchy

LevelTypical SizeSpeed (relative)
Registersfew KBFastest
Cache (L1/L2)tens KB – few MBVery fast
RAM (Main memory)GBFast
Secondary storage (HDD/SSD)TBSlower

5.4 Embedded Systems

  • Computers built into other devices (e.g., microwaves, cars, IoT sensors).
  • Typically have a microcontroller, limited memory, and run a single dedicated program.

5.5 Buses

  • Address bus – carries memory addresses from CPU to RAM.
  • Data bus – transfers actual data.
  • Control bus – carries timing and control signals (read/write, interrupt).

6. Software Fundamentals

6.1 System vs. Application Software

  • System software – operating system (OS) and utility programs; manages hardware resources.
  • Application software – programs that perform specific user tasks (e.g., word processor, web browser).

6.2 Operating System Functions

  • Resource management (CPU scheduling, memory allocation).
  • File management (creation, deletion, access control).
  • Input/Output handling.
  • Security & user authentication.
  • User interface (GUI or command line).

6.3 Interrupts

  • Hardware interrupt – generated by external devices (e.g., keyboard).
  • Software interrupt – generated by a program (e.g., system call).
  • CPU saves its current state, services the interrupt, then resumes the original task.

6.4 Development Tools

  • IDE (Integrated Development Environment) – combines editor, compiler/interpreter, debugger, and often a GUI builder.
  • Compiler – translates source code to machine code (e.g., C, Java).
  • Interpreter – executes source code line‑by‑line (e.g., Python).
  • Debugger – allows step‑through execution, breakpoints, and variable inspection.

6.5 Example Compilation Process (C language)

  1. Source code (.c) → pre‑processor (macro expansion, #include).
  2. Pre‑processed code → compiler (optimisation, conversion to assembly).
  3. Assembly → assembler (machine code object file .o).
  4. Object files + libraries → linker (produces executable .exe).

7. Internet and Its Uses

7.1 URL Structure

protocol://host[:port]/path?query#fragment

  • protocol – e.g., http, https, ftp.
  • host – domain name or IP address.
  • port – optional (default 80 for HTTP, 443 for HTTPS).
  • path – location of the resource on the server.
  • query – parameters passed to the server.
  • fragment – client‑side anchor.

7.2 HTTP vs. HTTPS

  • HTTP – unencrypted, data sent as plain text.
  • HTTPS – HTTP over TLS/SSL; provides confidentiality, integrity, and authentication.

7.3 Cookies

  • Small pieces of data stored by the browser on the client side.
  • Used for session tracking, preferences, and analytics.
  • Can raise privacy concerns; regulations (e.g., GDPR) require user consent.

7.4 Digital Currency (Basic Concepts)

  • Uses cryptographic techniques (hash functions, digital signatures).
  • Transactions recorded on a distributed ledger (blockchain).
  • Public‑key cryptography ensures only the owner can spend their coins.

7.5 Cyber‑Security Basics

  • Authentication – verifying identity (passwords, biometrics, 2‑FA).
  • Encryption – protects data in transit and at rest.
  • Firewalls – filter incoming/outgoing network traffic.
  • Malware – viruses, worms, ransomware; mitigated by anti‑virus software and safe practices.

8. Automated and Emerging Technologies

8.1 Sensors and Actuators

  • Sensors – convert physical quantities (light, temperature, motion) into electrical signals.
  • Actuators – convert electrical signals into physical movement (motors, solenoids).

8.2 Robotics

  • Combines sensors, actuators, control algorithms, and often AI for autonomous operation.
  • Typical components: microcontroller, power supply, motor drivers, feedback loops.

8.3 Artificial Intelligence (AI)

  • Expert systems – rule‑based decision making (IF‑THEN rules).
  • Machine learning – algorithms that improve from data (e.g., neural networks, decision trees).
  • AI is increasingly used for image recognition, natural‑language processing, and autonomous vehicles.

9. Algorithm Design and Problem Solving

9.1 Problem‑Solving (PDLC) Cycle

  1. Understand the problem.
  2. Analyse the problem (identify inputs, outputs, constraints).
  3. Design an algorithm (decomposition, flowchart, pseudocode).
  4. Implement the algorithm (write code).
  5. Test and debug (validation & verification).
  6. Refine/optimise if necessary.

9.2 Decomposition & Abstraction

  • Decomposition – break a large problem into smaller, manageable sub‑problems.
  • Abstraction – hide unnecessary detail; focus on the essential steps.

9.3 Flowchart Symbols (standard)

Create an account or Login to take a Quiz

39 views
0 improvement suggestions

Log in to suggest improvements to this note.