2. Topic 2(COLON) Data Representation and Encoding

Lesson 2.1: Binary, Denary And Hexadecimal

Official syllabus section covering Lesson 2.1: Binary, Denary and Hexadecimal within Topic 2: Data Representation and Encoding: Why computers use binary; bits, nibbles and bytes and units of storage (kB, MB, GB, and the binary and decimal distinction).; Converting between denary, binary and hexadecimal..

Lesson 2.1: Binary, Denary and Hexadecimal

Introduction

In this lesson, we will explore how computers represent and process information using binary, denary, and hexadecimal systems. Understanding these systems is crucial for any aspiring IT professional, as it forms the foundation of how data is stored and manipulated within a computer. By the end of this lesson, students will be able to:

  • Understand why computers predominantly use binary and recognize the concepts of bits, nibbles, and bytes.
  • Define units of storage such as kilobytes (kB), megabytes (MB), and gigabytes (GB), while grasping the difference between binary and decimal measurement.
  • Convert numbers between denary, binary, and hexadecimal systems.
  • Comprehend the importance of hexadecimal as a more compact, human-readable version of binary data representation.
  • Perform binary addition and understand how overflow occurs.

1. Why Computers Use Binary

1.1 Understanding Binary

At its core, binary is a base-2 numeral system that uses only two digits: 0 and 1. Every number or piece of information stored in a computer is ultimately reduced to binary because of how the physical components of computers work. Transistors, the fundamental building blocks of computer hardware, can be in one of two states: on (1) or off (0). This binary representation is efficient for computers as it reduces the complexity of electrical signals that must be processed.

1.2 Bits, Nibbles, and Bytes

  • Bit: A bit is the smallest unit of data in computing, representing a single binary value: either 0 or 1.
  • Nibble: A nibble consists of 4 bits. For example, the binary number 1010 is one nibble.
  • Byte: A byte contains 8 bits. It can represent 256 different values ranging from 0 to 255 in denary.

Example 1: Converting Bits to Bytes

If we have the binary sequence 11010101, we can break it down into the following components:

  • Bit 1: 1
  • Bit 2: 1
  • Bit 3: 0
  • Bit 4: 1
  • Bit 5: 0
  • Bit 6: 1
  • Bit 7: 0
  • Bit 8: 1

This entire sequence is one byte, which can also be represented in denary.

1.3 Units of Storage

There are several common units of storage, which we measure as follows:

  • Kilobyte (kB): 1 kB = 1024 bytes
  • Megabyte (MB): 1 MB = 1024 kB
  • Gigabyte (GB): 1 GB = 1024 MB

Common Misconception

It is important to clarify that while "kilo-" typically means 1000 in decimal terms, in computing, it refers to 1024 due to its binary basis. Thus, a kilobyte is actually larger than 1000 bytes.

2. Converting Between Denary, Binary, and Hexadecimal

2.1 Denary to Binary Conversion

To convert a denary number to binary, you can use successive division by 2 and record the remainders. The binary number is constructed by reading the remainders in reverse.

Example 2: Convert 13 to Binary

  1. Divide 13 by 2: quotient = 6, remainder = 1
  2. Divide 6 by 2: quotient = 3, remainder = 0
  3. Divide 3 by 2: quotient = 1, remainder = 1
  4. Divide 1 by 2: quotient = 0, remainder = 1

Reading the remainders from bottom to top, we find that 13 in denary is represented as 1101 in binary.

2.2 Binary to Denary Conversion

To convert binary back to denary, you take each bit and multiply it by $2^{n}$, where $n$ is the position of the bit starting from 0 (rightmost bit).

Example 3: Convert 1101 to Denary

  • Rightmost bit (1): $1 \times 2^{0} = 1$
  • Second bit (0): $0 \times 2^{1} = 0$
  • Third bit (1): $1 \times 2^{2} = 4$
  • Fourth bit (1): $1 \times 2^{3} = 8$

Adding these values together gives us:

$$1 + 0 + 4 + 8 = 13$$

2.3 Hexadecimal System

The hexadecimal system is base-16 and uses digits 0-9 and letters A-F to represent values.

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

Converting Binary to Hexadecimal

To convert binary to hexadecimal, group the binary digits into sets of four (starting from the right) and convert each group to its hexadecimal equivalent.

Example 4: Convert 11010101 to Hexadecimal

Group the binary into nibbles: 1101 0101

$- 1101 = D$

$- 0101 = 5$

So, $11010101_{(2)}$ is equivalent to $D5_{(16)}$.

3. Why Use Hexadecimal?

Hexadecimal is often used in computing as a shorthand for binary because it reduces complexity. A single hexadecimal digit can represent 16 values, whereas a single binary digit only represents 2 values. This makes it easier for humans to read and write large binary numbers.

Example 5: Comparing Lengths

  • Binary: $11111111$ (8 bits)
  • Hexadecimal: $FF$ (2 digits)

Hence, $11111111_{(2)} = FF_{(16)}$. This shows how hexadecimal simplifies representation while still retaining the ability to express the same values as binary.

4. Binary Addition and Overflow

In binary addition, the rules are similar to denary addition, but they are simplified:

  • $0 + 0 = 0$
  • $0 + 1 = 1$
  • $1 + 0 = 1$
  • $1 + 1 = 0$ (carry 1 to the next position)

Example 6: Performing Binary Addition

Let’s add the binary numbers $1101$ and $1011$:

  1101
+ 1011
------
  1. 1 + 1 = 0 (carry 1)
  2. 0 + 1 + (carry) 1 = 0 (carry 1)
  3. 1 + 0 + (carry) 1 = 0 (carry 1)
  4. 1 + 1 + (carry) 1 = 1 (carry 1)

Result is $11000$, demonstrating overflow where we cannot represent the additional carry in a fixed-width binary format.

Conclusion

In this lesson, we have delved into the underlying principles of binary, denary, and hexadecimal systems. students should now understand why binary is the prevalent system in computing, how to convert between these systems, and why hexadecimal is a useful form for representing binary numbers compactly. Additionally, students has learned to perform binary addition and recognize potential overflow situations.

Study Notes

  • Binary systems use two digits (0 and 1) and are fundamental for computing.
  • A bit is a single binary unit, a nibble consists of 4 bits, and a byte is 8 bits.
  • Storage units include kB (1024 bytes), MB (1024 kB), and GB (1024 MB).
  • To convert between systems, use division for denary to binary and multiplication for binary to denary.
  • Hexadecimal simplifies binary representation by grouping bits and using a base-16 system.
  • Binary addition operates under specific rules, with overflow occurring when results exceed fixed-width limits.

Practice Quiz

5 questions to test your understanding

Lesson 2.1: Binary, Denary And Hexadecimal — Information Technology | A-Warded