Data Storage and file compression

1.1.4 Addition of Binary Numbers

1.1.4.1 Example 1

The initial example provides a clear depiction of binary addition:

Problem:

Add the binary numbers 00100111 and 01001010.

Set Up:

The addition is expressed in column format along with carry values, organized as follows:

      0 0 1 0 0 1 1 1
    + 0 1 0 0 1 0 1 0
------------------------
 carry  1 1 1
  01110001
Column-by-Column Addition:
  1. Column 1: 1 + 0 = 1 (no carry)

  2. Column 2: 1 + 1 = 0 (carry 1)

  3. Column 3: 1 + 0 + 1 (from carry) = 0 (carry 1)

  4. Column 4: 0 + 1 + 1 (from carry) = 0 (carry 1)

  5. Column 5: 0 + 0 + 1 (from carry) = 1 (no carry)

  6. Column 6: 1 + 0 = 1 (no carry)

  7. Column 7: 0 + 1 = 1 (no carry)

  8. Column 8: 0 + 0 = 0 (no carry)

Answer:

Thus, the result of the addition yields 01110001.

1.1.4.2 Additional Exercises

a. Convert the following denary numbers into binary:
  • 126 = 01111110

  • 62 = 00111110

b. Add the two binary values obtained above:
  01111110
+ 00111110
------------
  10111100
Column-by-Column Addition:
  1. Column 1: 0 + 0 = 0 (no carry)

  2. Column 2: 1 + 1 = 0 (carry 1)

  3. Column 3: 1 + 1 + 1 (from carry) = 1 (carry 1)

  4. Column 4: 1 + 1 + 1 (from carry) = 1 (carry 1)

  5. Column 5: 1 + 1 + 1 (from carry) = 1 (carry 1)

  6. Column 6: 1 + 0 + 1 = 0 (carry 1)

  7. Column 7: 0 + 0 + 1 (from carry) = 1 (no carry)

Answer Validation:

The binary result 10111100 converts back to a denary value:

  • 128 + 32 + 16 + 8 + 4 = 188

This confirms the addition as correct since 126 + 62 equals 188.

1.1.5 Activities on Binary Addition

1.1.5.1 Activity 1.8

Carry out the following binary additions:

  • a. 00011101 + 01100110

  • b. 00100111 + 00111111

  • c. 00101110 + 01001101

  • d. 01110111 + 00111111

  • e. 00111100 + 00110011

  • f. 00111100 + 01111011

  • g. 00111111 + 00111111

  • h. 00110001 + 0011111

  • i. 01111111 + 01111111

  • j. 10100010 + 00111011

1.1.5.2 Activity 1.9

Convert the following denary numbers into binary, then carry out binary addition and check against the denary sum:

  • a. 98 + 15

  • b. 29 + 88

  • c. 49 + 100

  • d. 51 + 171

  • e. 82 + 69

  • f. 100 + 140

  • g. 19 + 139

  • h. 203 + 30

  • i. 66 + 166

  • j. 211 + 35

1.1.6 Binary Addition Leading to Overflow

Binary Example:

Add together the following binary values:

   01101110
+  11011110
-----------------
   01001100 (8 bits)
Note: 9th Bit

The addition generates a 9th bit, indicating overflow:

  • The 8 bits yield 01001100 which translates to a denary value of 76.

  • Yet, the actual sum of 110 + 222 is 332.

Limitation of 8-bit Representation:
  • The maximum denary limit of an 8-bit binary number is 255 (or 2812^8 - 1).

  • Overflow indicates the impossibility of storing numbers beyond this limit correctly.

1.1.7 Shifting Operations in Binary

1.1.7.1 Left Shift Example

Starting with 21 (denary) which translates to binary as 00010101:

  • Shift 1 Place Left:

  00010101  (21)
= 00101010  (42, as 21 × 2)
  • Resulting in the denary value of 42.

Shifting Left Further:
  1. Two Places Left:

  00010101
= 01010100 (84, as 21 × 2²)
  1. Three Places Left:

  00010101
= 10101000 (168, as 21 × 2³)
  1. Four Places Left:
    ``