1. Number system
IGCSE Computer Science (0478)
  • Data Representation
    • Introduction
    • Why computers use binary (how binary represents data)
    • Number system
      • Introduction
      • Number Conversions
      • Addition of Binary Numbers
      • Logical binary shifts (positive 8-bit integers)
      • Two’s Complement (Signed: Positive and Negative Numbers)
      • Use of the Hexadecimal System
    • Text, Sound and Image
      • Text, Sound and Images
      • File Types
    • Data storage and File compression
      • Measurement of the Size of Computer Memories
      • Lossless and Lossy File Compression
  1. Number system

Addition of Binary Numbers

Addition of Binary Numbers (Adding Two Positive 8-bit Numbers)#

Binary Addition Rules#

Bit 1Bit 2Carry Happens? (Carry Out = 1)Sum
00❌ No0
01❌ No1
10❌ No1
11✅ Yes (Carry Out = 1)0

What is a Carry?#

When adding bits, if the total is 2 (which is '10' in binary), write 0 and carry 1 to the next left bit.
If total is 3 ('11' in binary), write 1 and carry 1.

Binary Addition examples:#

a) Add 45 + 100 (8-bit)#

Step 1: Convert to 8-bit binary
45 = 00101101
100 = 01100100
Step 2: Add bit by bit
Bit Position87654321
Number 100101101
Number 201100100
Carry In00101100
Sum01011011
Result:
Sum (8-bit): 01011011 (91 in decimal)

b) Add 12 + 34 (8-bit)#

Step 1: Convert to 8-bit binary
12 = 00001100
34 = 00100010
Step 2: Add bit by bit
Bit Position87654321
Number 100001100
Number 200100010
Carry In00001100
Sum00101110
Result:
Sum (8-bit): 00101110 (46 in decimal)

c) Add 78 + 57 (8-bit)#

Step 1: Convert to 8-bit binary
78 = 01001110
57 = 00111001
Step 2: Add bit by bit
Bit Position87654321
Number 101001110
Number 200111001
Carry In00101110
Sum10000111
Result:
Sum (8-bit): 10000111 (135 in decimal)

d) Add 150 + 50 (8-bit)#

Step 1: Convert to 8-bit binary
150 = 10010110
50 = 00110010
Step 2: Add bit by bit
Bit Position87654321
Number 110010110
Number 200110010
Carry In01010110
Sum11001000
Result:
Sum (8-bit): 11001000 (200 in decimal)

Some examples with Overflow#

If the sum requires more bits than available (e.g., result is 9 bits but only 8 bits allowed), the extra bit is called overflow.
Overflow means the result can’t fit in the assigned number of bits.

Working Example:#

a) Add 01101110(110) + 11011110(222)#

Bit Position87654321
Number 101101110
Number 211011110
Carry In11111100
Sum00100100
Result:
Binary Sum: 00101100
Decimal:
01101110 = 110
11011110 = 222
Total = 332 (overflow)
8-bit Truncated: 00101100 = 44 (due to overflow)
Key Point: The 9th carry bit was discarded, causing overflow (332 > 255). The 8-bit result is incorrect.

b) Add 89 + 175 (8-bit)#

Step 1: Convert to 8-bit binary
89 = 01011001
175 = 10101111
Step 2: Add bit by bit
Bit Position87654321
Number 101011001
Number 210101111
Carry In11110110
Sum00001000
Result:
Short Answer:
Sum (8-bit): 00001000 (8 in decimal)
Overflow: Yes (carry out from MSB) → True sum (264) exceeds 8-bit range (0-255).

Explanation:#

89 + 175 = 264, but 8-bit max is 255.
Binary addition yields 00001000 (8) with a carry out, indicating overflow.
Correct result requires 9 bits: 100001000 (264).

c) Add 168 + 99 (8-bit)#

Here's the improved version with the explanation integrated:
Step 1: Convert to 8-bit binary
89 = 01011001
175 = 10101111
Step 2: Add bit by bit
Bit Position87654321
Number 101011001
Number 210101111
Carry In11011000
Sum10000100
Result:
8-bit Result: 00001000 = 8 (decimal) ❌
(This is obtained by taking only the rightmost 8 bits of the sum and discarding the 9th overflow bit)
Actual sum in decimal: 89 + 175 = 264 → exceeds 255 → unsigned overflow occurs.
(The correct 9-bit result is 100001000, but 8-bit systems can only store 00001000)

d) Add 88 + 215 (8-bit)#

Step 1: Convert to 8-bit binary
88 = 01011000
215 = 11010111
Step 2: Add bit by bit with carries
Bit Position87654321
Number 101011000
Number 211010111
Carry11110000
Sum00110111
Result:
8-bit Result: 00110111 = 55 (decimal) ❌
(Only the rightmost 8 bits are kept, discarding the overflow carry)
Actual sum in decimal: 88 + 215 = 303 → exceeds 255 → unsigned overflow occurs.
(Full 9-bit result would be 100110111, but 8-bit truncation gives incorrect 00110111)
Key Observation:
The 9th carry bit (1) indicates overflow, making the 8-bit result invalid.

16-bit Addition Practice Solutions#


a) Add#

0111 1111 1111 0001 + 0101 1111 0011 1001
Bit Position16151413121110987654321
Number 10111111111110001
Number 20101111100111001
Carry In0111111100110000
Sum1101111100101010
Result:
16-bit Result: 1101 1111 0010 1010 (0xDF2A) = 57,130 ✅
Actual sum: 32,753 + 24,377 = 57,130 → No overflow (≤65,535)
Note: All carries propagate correctly without final overflow (no 17th bit generated). The result matches manual calculation:
0x7FF1 (32,753) + 0x5F39 (24,377) = 0xDF2A (57,130)

b) Add#

1110 1110 0000 1011 + 1111 1101 1101 1001
Bit Position16151413121110987654321
Number 11110111000001011
Number 21111110111011001
Carry In1111111000001011
Sum1110110000000000
Result:
16-bit Result: 1110 1100 0000 0000 (0xEC00)
Actual sum in decimal: 60,939 + 64,985 = 125,924
Overflow: ❌ (Result requires 17 bits, but only 16 are available)
Verification:
1.
Full 17-bit result would be 1 1110 1100 0000 0000 (121,344)
2.
16-bit truncation gives 1110 1100 0000 0000 (60,416)
3.
Correct sum (125,924) > 65,535 → Overflow occurs
Key Observation:
The discarded 17th carry bit (1) indicates overflow, making the 16-bit result invalid. The truncated value (60,416) is incorrect due to overflow.
Modified at 2025-08-12 06:15:32
Previous
Number Conversions
Next
Logical binary shifts (positive 8-bit integers)
Built with