Welcome to Data Representation!

Ever wondered how a computer, which is basically a collection of tiny switches, can show you a high-definition movie or keep track of your high score in a game? It all comes down to Data Representation. In this chapter, we will learn how computers "translate" our world of numbers and letters into their own language: Binary.

Don't worry if you find numbers a bit intimidating—we will break everything down into simple steps. Think of this like learning a secret code!


1. The Three Number Systems

To understand computers, we need to know three specific "languages" or number systems:

A. Denary (Base-10)

This is the "human" system we use every day (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). We use 10 digits because we have 10 fingers!

B. Binary (Base-2)

This is the "computer" system. It only uses two digits: 0 and 1.
Analogy: Think of a light switch. It can only be OFF (0) or ON (1). A computer is made of billions of these tiny switches.

C. Hexadecimal (Base-16)

This system uses 16 symbols. Since we ran out of numbers after 9, we use letters:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A (10), B (11), C (12), D (13), E (14), F (15).
Why use Hex? It’s much shorter than binary and easier for humans to read without making mistakes.

Quick Review:
- Denary: Humans (0-9)
- Binary: Computers (0-1)
- Hexadecimal: Shorthand for humans (0-F)


2. Converting Between Systems

Being able to convert numbers is a core skill for GCE O-Level Computing. Let's look at how to do this step-by-step.

Binary to Denary

To convert binary to denary, we use a Place Value Table. In binary, the values double every time you move left.

Example: Convert 10110010 to Denary
1. Draw the table (start from 1 on the right and double as you move left):

\( \begin{array}{|c|c|c|c|c|c|c|c|}\n\hline\n128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 \\\n\hline\n1 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\\n\hline\n\end{array} \)

2. Add up the numbers that have a '1' under them:
\( 128 + 32 + 16 + 2 = 178 \)

Denary to Binary

Use the Subtraction Method.
Mnemonic: "Find the biggest fit."

Example: Convert 75 to Binary
1. Can 128 fit into 75? No (0)
2. Can 64 fit into 75? Yes! (1). Remainder: \( 75 - 64 = 11 \)
3. Can 32 fit into 11? No (0)
4. Can 16 fit into 11? No (0)
5. Can 8 fit into 11? Yes! (1). Remainder: \( 11 - 8 = 3 \)
6. Can 4 fit into 3? No (0)
7. Can 2 fit into 3? Yes! (1). Remainder: \( 3 - 2 = 1 \)
8. Can 1 fit into 1? Yes! (1). Remainder: 0
Result: 01001011

Hexadecimal to Binary

This is the easiest! Each Hex digit is exactly 4 binary bits (called a nibble).

Example: Convert 2A to Binary
1. Convert '2' to a 4-bit binary: 0010
2. Convert 'A' (which is 10) to a 4-bit binary: 1010
3. Put them together: 00101010

Key Takeaway: Always use a table for binary conversions! It prevents simple addition errors.


3. Two's Complement (Negative Numbers)

Normal binary only represents positive numbers. To represent negative numbers, we use Two's Complement.
Don't worry if this seems tricky at first; just follow the "Flip and Add" rule!

How to convert a positive number to negative (e.g., -5):

1. Start with the positive binary version (using 8 bits):
\( 5 = 00000101 \)

2. Flip all the bits (0 becomes 1, 1 becomes 0):
\( 11111010 \)

3. Add 1 to the result:
\( 11111010 + 1 = 11111011 \)
Result: 11111011 represents -5.

Why do we do this?

In Two's Complement, the most significant bit (the one on the far left) acts as a negative sign. In an 8-bit system, the first column is actually -128 instead of +128.

Quick Review:
1. Write positive binary.
2. Flip bits.
3. Add 1.


4. Representing Text (ASCII)

Computers don't know what the letter 'A' is. They only know numbers. So, we use a "codebook" called ASCII (American Standard Code for Information Interchange).

8-bit Extended ASCII

In 8-bit Extended ASCII, every character (letter, number, or symbol) is assigned a unique number from 0 to 255.

How it works:
- When you press 'A' on your keyboard, the computer sees the denary number 65.
- It then converts 65 into binary: 01000001.
- This binary string is what is stored in the memory.

Did you know? The difference between uppercase 'A' (65) and lowercase 'a' (97) is exactly 32. This makes it easy for computers to switch between cases by just changing one bit!

Summary of Text Representation:
  • Characters are mapped to numbers using the ASCII standard.
  • 8-bit encoding means we can represent \( 2^8 \) (256) different characters.
  • This includes English letters, punctuation, and special symbols.

Chapter Summary - Key Points to Remember

1. Binary is the base-2 system used by computers (0s and 1s).

2. Hexadecimal is base-16 and is used because it is easier for humans to read and write than long strings of binary.

3. Conversions are best done using place-value tables (1, 2, 4, 8, 16, 32, 64, 128).

4. Two's Complement is the method used to represent negative numbers in binary. Remember: Flip and Add 1.

5. ASCII is the standard "code" that allows computers to represent text as binary numbers.

Common Mistake to Avoid: When doing Two's Complement, many students forget to add the '1' at the end. Always double-check your final step!