1.1 Data Representation

Number systems

1. The Concept of Base

A number system is defined by its base (or radix), which dictates the number of unique digits available and the positional value of each digit.

The Rule: For any system with base $n$, the digits range from $0$ to $n-1$. For example, Base 2 (Binary) uses only $0$ and $1$.

2. Key Systems Comparison

System Base Digits/Symbols Primary Purpose
Denary 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Human-centric calculations.
Binary 2 0, 1 Internal processing (Logic gates/Transistors).
Hexadecimal 16 0-9 and A-F Memory addresses, Color codes (HTML), MAC addresses.

3. Binary (Base 2)

Computers use binary because they are made of electronic circuits that can only exist in two states: High Voltage (1) or Low Voltage (0).

Place Values

Binary values are calculated using powers of 2. For a standard 8-bit byte:

2726252423222120
1286432168421

4. Hexadecimal (Base 16)

Hexadecimal uses 16 symbols. After 9, we use letters to represent values from 10 to 15:

A=10 | B=11 | C=12 | D=13 | E=14 | F=15

Why do we use Hex?

Many students mistakenly think computers "understand" Hex. They do not. We use it for the following human-centric reasons:

  • Readability: It is much easier to read 3F than 00111111.
  • Efficiency: It is faster to type and takes up less screen space.
  • Error Reduction: Humans are less likely to make mistakes when copying Hex compared to long strings of 1s and 0s.
  • Easy Mapping: One Hex digit perfectly represents exactly one nibble (4 bits).

5. Data Storage Units

The IGCSE syllabus requires knowledge of the difference between Base 10 (Metric) and Base 2 (IEC) units:

  • Bit: The smallest unit of data.
  • Byte: 8 bits.
  • Kibibyte (KiB): 1024 bytes ($2^{10}$).
  • Mebibyte (MiB): 1024 KiB ($2^{20}$).
  • Gibibyte (GiB): 1024 MiB ($2^{30}$).

Binary and Denary Systems

1. The Denary System (Base 10)

Denary is the standard numbering system used by humans. It is positional, meaning the value of a digit depends on its place in the number.

Example: In the number 523, the '5' represents 5 hundreds, the '2' represents 2 tens, and the '3' represents 3 units.

Denary Place Values

103 102 101 100
1000 100 10 1

2. The Binary System (Base 2)

Binary uses only two digits: 0 and 1. In a computer, these represent the absence or presence of an electrical pulse.

Binary Place Values (The 8-bit Byte)

To convert between systems, always write out your binary grid first:

1286432168421
2726252423222120

3. Conversion: Binary to Denary

To convert a binary number to denary, simply add the place values where a '1' appears.

Example: Convert 10101000 to Denary
  • 128 + 0 + 32 + 0 + 8 + 0 + 0 + 0
  • $128 + 32 + 8 = 168$
  • Result: 168

4. Conversion: Denary to Binary

There are two main methods. The "Subtraction Method" is often the most intuitive for IGCSE students:

  • Start from the left of the binary grid (128).
  • Check if the Denary number is greater than or equal to the place value.
  • If YES: Write a 1 and subtract the place value from your total.
  • If NO: Write a 0 and move to the next place value on the right.
  • Repeat until you reach the '1' column.
Example: Convert 75 to Binary
  1. Is $75 \ge 128$? No (0)
  2. Is $75 \ge 64$? Yes (1). Remaining: $75 - 64 = 11$
  3. Is $11 \ge 32$? No (0)
  4. Is $11 \ge 16$? No (0)
  5. Is $11 \ge 8$? Yes (1). Remaining: $11 - 8 = 3$
  6. Is $3 \ge 4$? No (0)
  7. Is $3 \ge 2$? Yes (1). Remaining: $3 - 2 = 1$
  8. Is $1 \ge 1$? Yes (1). Remaining: 0
Result: 01001011

5. Maximum Values

It is useful to remember the capacity of a standard 8-bit byte:

  • Smallest value: 00000000 (0)
  • Largest value: 11111111 (255)
  • Total combinations: $2^8 = 256$ different values.

Hexadecimal System (Base-16)

1. The Hexadecimal Concept

Hexadecimal is a Base-16 system. Because we only have 10 digits (0-9) in our standard alphabet, we use letters to represent values from 10 to 15.

Denary 0123456789101112131415
Hex 0123456789ABCDEF

2. Converting Binary to Hexadecimal

This is the most common task in IGCSE exams. It works because $16$ is a power of $2$ ($2^4 = 16$). One Hex digit represents exactly 4 bits (a nibble).

Method: The 4-Bit Grouping
  1. Take a binary string (e.g., 10110110).
  2. Split it into two 4-bit nibbles: 1011 and 0110.
  3. Convert each nibble to Denary:
    • 1011 = $8 + 2 + 1 = 11$
    • 0110 = $4 + 2 = 6$
  4. Convert those values to Hex:
    • $11$ becomes B
    • $6$ remains 6
Final Answer: B6

3. Converting Hexadecimal to Denary

Just like Binary and Denary, Hex uses place values. However, the multipliers are powers of 16.

Example: Convert 2A to Denary

Write the place values: 16s and 1s.

  • $(2 \times 16) + (A \times 1)$
  • Since $A = 10$, the calculation is: $(2 \times 16) + (10 \times 1)$
  • $32 + 10 = 42$
Result: 42

4. Practical Applications in CS

You may be asked where Hex is used in the real world. Memorize these three:

  • MAC Addresses: Media Access Control addresses (e.g., 00:1A:2B:3C:4D:5E).
  • HTML/CSS Color Codes: Using RGB values (e.g., #FF5733).
  • Memory Dumps / Debugging: Displaying the contents of RAM to help programmers find errors.
  • Assembly Language: To represent machine code instructions in a readable way.

5. Common Pitfall: Storage Myth

⚠️ Exam Warning: Hexadecimal does not save storage space. Computers never store data as Hex; they convert everything back to Binary (1s and 0s) for processing. Hex is strictly for human readability.

Binary Prefixes

1. The Two Standards

Historically, the term "Kilobyte" was used to mean 1024 bytes. However, to stay consistent with scientific SI units, the IEC (International Electrotechnical Commission) introduced specific Binary Prefixes.

Metric (SI) Units

Based on Powers of 10. Used by drive manufacturers and in networking.

103 = 1,000

Example: Kilobyte (kB)

Binary (IEC) Units

Based on Powers of 2. Used by Operating Systems and for RAM.

210 = 1,024

Example: Kibibyte (KiB)

2. The Binary Prefix Table

For the IGCSE exam, you must use the 1024-based names when referring to memory sizes.

Unit Name Abbreviation Value (Bytes) Power of 2
Kibibyte KiB 1,024 210
Mebibyte MiB 1,048,576 220
Gibibyte GiB 1,073,741,824 230
Tebibyte TiB 1,099,511,627,776 240
Pebibyte PiB 1,125,899,906,842,624 250

3. Smallest Units of Data

  • Bit: A single 0 or 1. (Short for Binary Digit).
  • Nibble: A group of 4 bits.
  • Byte: A group of 8 bits. (The standard unit for one character of text).

4. Conversion Formulas

Exam Tip: When calculating data sizes, always multiply or divide by 1024, not 1000.
Smaller to Larger Larger to Smaller
Divide by 1024 Multiply by 1024
(e.g., KiB to MiB) (e.g., GiB to MiB)

Example Calculation:

How many MiB are in 2 GiB?

$2 \times 1024 = 2048 \text{ MiB}$

Binary Addition and Overflow

1. The Four Rules of Binary Addition

Binary addition follows the same logic as denary addition (carrying values to the next column), but you only have two digits to work with.

$0 + 0 = 0$
$0 + 1 = 1$
$1 + 1 = 10$
(0 carry 1)
$1 + 1 + 1 = 11$
(1 carry 1)

2. Addition Example

When adding binary numbers, always start from the Right (the Least Significant Bit).

 111     (Carries)
 01101010 (106)
+00011100 (28)
10000110 (134)

3. Overflow Errors

In IGCSE Computer Science, we usually work with 8-bit registers. An 8-bit register can store a maximum value of 255 ($11111111$).

Definition: An Overflow Error occurs when the result of a binary addition exceeds the maximum capacity of the register (e.g., the result needs 9 bits but only 8 are available).

Example of Overflow:

Attempting to add $150 + 150$ in an 8-bit register:

11       
  10010110 (150)
+ 10010110 (150)
100101100 (300)

The 9th bit (highlighted in red) has nowhere to go. The CPU simply drops it.

4. Consequences of Overflow

  • Data Loss: The computer "ignores" the extra bit, leading to an mathematically incorrect result (e.g., $150+150$ might appear to equal $44$).
  • System Crashes: In some cases, an unexpected overflow can cause a program to crash or behave unpredictably.
  • Security Risks: Hackers sometimes use "Buffer Overflows" to gain control of a system by forcing data into memory it shouldn't access.

5. Logical Binary Shifts

While not addition, shifting bits is a form of arithmetic often linked to this topic:

  • Left Shift ($\ll$): Multiplies the number by 2 for every place shifted.
  • Right Shift ($\gg$): Divides the number by 2 (integer division) for every place shifted.
1 + 1 is 10, not 2!

Character Sets

1. What is a Character Set?

A Character Set is a defined list of characters recognized by computer hardware and software. Each character is assigned a unique binary number (binary code).

Without a character set, a computer would just see a string of bits and wouldn't know if they represented a number, a sound, or the letter 'A'.

2. ASCII (American Standard Code for Information Interchange)

ASCII was the first widely used character set. It originally used 7 bits, providing $2^7$ ($128$) unique characters.

Example Mapping:
Character 'A' → Denary 65 → Binary 01000001
Character 'a' → Denary 97 → Binary 01100001
Character '!' → Denary 33 → Binary 00100001

Extended ASCII: Later updated to 8 bits ($2^8$), allowing for $256$ characters. This added mathematical symbols and some non-English characters.

3. Unicode

As computing went global, 256 characters weren't enough for languages like Chinese, Arabic, or Hindi. Unicode was created to represent every character in every language.

  • Uses 16 bits (65,536 characters) or 32 bits (over 4 billion characters).
  • The first 128 codes in Unicode are identical to ASCII, making it "backward compatible."
  • Includes Emojis and historical scripts (like Hieroglyphics).

4. ASCII vs. Unicode: Comparison

Feature ASCII Unicode
Bits per Character 7 or 8 bits 16 or 32 bits
Number of Characters 128 to 256 Over 1 million (currently)
Storage Requirements Low (1 byte per char) High (2 to 4 bytes per char)
Global Use English/Western only Universal (all languages)

5. Key Exam Terms

Character:
A single symbol (letter, number, or punctuation mark).
Alphanumeric:
Characters that include both letters and numbers.
Control Characters:
Non-printing characters that perform actions, such as "Shift," "Backspaced," or "Enter."
💡 Exam Tip: If an exam question asks why Unicode is better than ASCII, mention that it allows for global communication and supports multilingual applications, even though it requires more storage space.