Representing Data
What is Data Representation?
Data representation refers to how computers store, process, and manipulate information using different formats. Since computers operate in binary (0s and 1s), all types of data must be represented in a format that is readable by digital circuits.Types of Data Representation
Binary Representation
Binary is the foundational language of computers, using only two digits: 0 and 1. This system works well with digital electronics, which have two physical states-on and off, or high and low voltage. Each digit in binary is called a bit. In binary, the position of each bit represents a power of 2.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 |
The binary number above, 10101011, is 128 + 32 + 8 + 2 + 1, or in 171 denary.
Hexadecimal Representation
Hexadecimal (base-16) is used as a more human-readable representation of binary. It uses digits 0–9 and letters A–F to represent values. It is widely used in programming, color codes (e.g. #FF5733), and memory addressing because it compresses long binary sequences into fewer characters, making it easier to read on-screen.
In hexadecimal, the position of each digit represents a power of 16.
| 256 | 16 | 1 |
|---|---|---|
| 0 | 1 | A |
The hexadecimal number above, 01A, is 0 + 16 + 10, or in 26 denary.
One hex digit represents four bits (a nibble), so the binary value 1101 equals the hexadecimal value D.
| Binary | |||
|---|---|---|---|
| 8 | 4 | 2 | 1 |
| 1 | 1 | 0 | 1 |
| Hex |
|---|
| D |
Example: The binary number 1101 1010 is grouped into two nibbles: 1101 and 1010, which correspond to the hexadecimal digits D and A. So, 11011010 is DA, which is easier to read.
Character Encoding: ASCII and Unicode
Textual data is stored using character encoding systems. ASCII (American Standard Code for Information Interchange), developed in the 1960s in the United States, was one of the earliest standards. It represents 128 characters using 7 bits-sufficient for English letters, digits, punctuation, and control characters, but limited to the Latin alphabet.
Unicode was introduced to address this limitation, enabling the representation of thousands of characters from diverse languages and scripts worldwide through formats like UTF-8 and UTF-16. It supports global communication, including non-Latin scripts such as Arabic, Chinese, Cyrillic, and Devanagari.
Unicode is ethically a better choice because it promotes inclusivity and linguistic diversity, allowing people around the world to use their native scripts digitally-essential for preserving language, culture, and identity in an interconnected world.
Binary, Hexadecimal, and Decimal Conversion
Understanding how to convert between number systems is essential for data representation and computing tasks. Below are common methods and worked examples to convert between binary (base-2), decimal (base-10), and hexadecimal (base-16).
Binary to Decimal Conversion
To convert binary to decimal, multiply each bit by the power of 2 that corresponds to its position, starting from the right (0-based index), then sum the results.
Example: Convert 10101101 to decimal.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
Decimal = (1×128) + (0×64) + (1×32) + (0×16) + (1×8) + (1×4) + (0×2) + (1×1) = 173
Decimal to Binary Conversion
To convert decimal to binary, repeatedly divide the decimal number by 2 and record the remainders. The binary number is formed by reading the remainders in reverse order (bottom to top).
Example: Convert 173 to binary.
- 173 ÷ 2 = 86 remainder 1
- 86 ÷ 2 = 43 remainder 0
- 43 ÷ 2 = 21 remainder 1
- 21 ÷ 2 = 10 remainder 1
- 10 ÷ 2 = 5 remainder 0
- 5 ÷ 2 = 2 remainder 1
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
Binary = 10101101
Binary to Hexadecimal Conversion
Group the binary digits into sets of 4 from right to left, then convert each group to its hexadecimal equivalent.
Example: Convert 11011010 to hexadecimal.
Group: 11011010 → Hex: D A → DA
| Nibble 1 | Nibble 2 | ||||||
|---|---|---|---|---|---|---|---|
| 8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| D | A | ||||||
Hexadecimal to Binary Conversion
Convert each hex digit to its 4-bit binary equivalent.
Example: Convert AB to binary.
A = 1010, B = 1011 → Binary: 10101011
Key Takeaways
- All digital data is ultimately represented in binary, using only two states: 0 and 1.
- Binary representation relies on powers of 2, with each bit's position determining its value.
- Hexadecimal is used as a more compact and readable format for binary, especially in memory addressing and colour codes.
- Character encodings like ASCII and Unicode map binary values to readable text and symbols.
- Unicode supports global communication by enabling multilingual digital representation, unlike ASCII's limited range.