Add two positive 8-bit binary integers

Resources | Subject Notes | Computer Science

Data Representation - Adding 8-bit Binary Integers

Data Representation - Adding 8-bit Binary Integers

Objective

To understand and implement the process of adding two positive 8-bit binary integers.

Understanding 8-bit Binary Integers

An 8-bit binary integer is a whole number represented using 8 binary digits (bits), each of which can be either 0 or 1. This allows for representing numbers from 0 to 255 (inclusive). Each bit position represents a power of 2, starting from the rightmost bit as 20, then 21, 22, and so on.

Addition Algorithm

The process of adding two 8-bit binary integers involves performing binary addition, similar to decimal addition, but using the rules of binary arithmetic. We consider each bit position, starting from the least significant bit (rightmost), and perform the addition and carry operation.

Binary Addition Rules

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 10 (which is 0 with a carry-over of 1)

Example: Adding 10110011 and 01010101

Let's add the binary numbers 10110011 and 01010101:

  1. Rightmost bit (20): 1 + 1 = 10. Write down 0, carry-over 1.
  2. Next bit (21): 1 + 0 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  3. Next bit (22): 0 + 1 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  4. Next bit (23): 1 + 0 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  5. Next bit (24): 1 + 0 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  6. Next bit (25): 0 + 1 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  7. Next bit (26): 1 + 0 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  8. Leftmost bit (27): 1 + 0 + 1 (carry-over) = 10. Write down 0, carry-over 1.
  9. The final result is 10000100.

Table Representation of the Addition Process

Bit Position Addend (10110011) Target (01010101) Sum Carry
27 1 0 1 0
26 0 1 1 0
25 1 0 0 1
24 1 1 0 1
23 0 1 0 1
22 0 0 0 1
21 1 1 0 1
20 1 1 0 1

Result

The sum of 10110011 and 01010101 is 10000100.

Verification

Converting the binary numbers to decimal: 10110011 = 187 and 01010101 = 85. Their sum is 187 + 85 = 272. Converting 10000100 to decimal gives 128 + 64 + 4 = 272. Therefore, the addition is correct.