Docsity

Complements in Digital Computers: A Comprehensive Guide with Examples, Study notes of Digital Electronics

Toggle sidebar
bg1
Complements
Purpose:
o Used in digital computers to simplify subtraction operations.
o Important for logical manipulations.
Types of Complements:
1. r's Complement (Radix Complement)
2. (r - 1)'s Complement
Complements in Various Number Systems:
• Binary System (Base 2):
o r’s complement = 2’s complement
o (r – 1)’s complement = 1’s complement
• Decimal System (Base 10):
o r’s complement = 10’s complement
o (r – 1)’s complement = 9’s complement
• Octal System (Base 8):
o r’s complement = 8’s complement
o (r – 1)’s complement = 7’s complement
• Hexadecimal System (Base 16):
o r’s complement = 16’s complement
o (r – 1)’s complement = 15’s complement
Radix Complement (r’s complement):
• For a given positive number N in base r, with n digits:
o r's complement = 𝑟𝑛− 𝑁(𝑖𝑓 𝑁 ≠ 0)
o If N = 0, then r's complement is simply 0
Example 1.26. Find the 10’s complement of
(23450)10. Solution:
𝑛 = 5, 𝑁 = 23450, 𝑟 = 10
The 10’s complement of (23450)10 = 𝑟𝑛 − 𝑁 = 105 − 23450 = 𝟕𝟔𝟓𝟓𝟎
Example 1.27. Find the 10’s complement of
(0.3245)10. Solution:
𝑛 = 0, 𝑁 = 0.3245, 𝑟 = 10
The 10’s complement of (0.3245)10 = 𝑟𝑛 − 𝑁 = 100 − 0.3245 = 𝟎.
𝟔𝟕𝟕𝟓𝟓
Example 1.28. Find the 10’s complement of
(23.324)10. Solution:
𝑛 = 2, 𝑁 = 23.324, 𝑟 = 10
The 10’s complement of (23.324)10 = 𝑟𝑛 − 𝑁 = 102 − 23.324 = 𝟕𝟔.
𝟔𝟕𝟔
Example 1.29. Find the 2’s complement of
(10110)2. Solution:
𝑛 = 5, 𝑁 = 10110, 𝑟 = 2
The 2’s complement of (10110)2 = 𝑟𝑛 − 𝑁 = (25)10 − (10110)2
= (32)10 − (10110)2 = (100000)2 −
(10110)2
= (100000)2 − (10110)2 = 𝟎𝟏𝟎𝟏𝟎
pf3
pf4
pf5

Partial preview of the text

Download Complements in Digital Computers: A Comprehensive Guide with Examples and more Study notes Digital Electronics in PDF only on Docsity!

Complements

Purpose:

o Used in digital computers to simplify subtraction operations.

o Important for logical manipulations.

Types of Complements:

  1. r's Complement (Radix Complement)
  2. (r - 1)'s Complement

Complements in Various Number Systems:

  • Binary System (Base 2) :

o r’s complement = 2’s complement

o (r – 1)’s complement = 1’s complement

  • Decimal System (Base 10) :

o r’s complement = 10’s complement

o (r – 1)’s complement = 9’s complement

  • Octal System (Base 8) :

o r’s complement = 8’s complement

o (r – 1)’s complement = 7’s complement

  • Hexadecimal System (Base 16) :

o r’s complement = 16’s complement

o (r – 1)’s complement = 15’s complement

Radix Complement (r’s complement):

  • For a given positive number N in base r, with n digits:

o r's complement = 𝑟

𝑛

o If N = 0 , then r's complement is simply 0

Example 1.26. Find the 10’s complement of

( 23450 ) 10. Solution:

The 10’s complement of ( 23450 ) 10 = 𝑟

𝑛

5

Example 1.27. Find the 10’s complement of

(0.3245) 10. Solution:

The 10’s complement of

10

𝑛

0

Example 1.28. Find the 10’s complement of

  1. Solution:

The 10’s complement of (23.324) 10 = 𝑟

𝑛

2

Example 1.29. Find the 2’s complement of

( 10110 ) 2. Solution:

The 2’s complement of ( 10110 ) 2 = 𝑟

𝑛

5

Example 1.30. Find the 2’s complement of

  1. Solution:

The 2’s complement of

𝑛

0

2

2

Example 1.31. Find the 8’s complement of

8

. Solution:

The 8’s complement of

𝑛

4

8

10

Example 1.32. Find the 16’s complement of

(4A30) 16. Solution:

𝑛 = 4, 𝑁 = 4A30, 𝑟 = 16

The 16’s complement of (4A30) 16 = 𝑟

𝑛

4

) 10 − (4A30) 16

10

Formula for (r – 1)'s complement:

The formula for finding the (r – 1)'s complement is:

Where:

  • 𝑁 is the number.
  • 𝑛 is the number of digits in the integer part of the number.
  • 𝑚 is the number of digits in the fractional part of the number.
  • 𝑟 is the base of the number system (here, 𝑟 = 10 ).

Example 1.33. Find the 9’s complement of

( 23450 ) 10. Solution:

The 9’s complement of

𝑛

− 𝑚

5

0

𝟏𝟎

Example 1.34. Find the 9’s complement of

  1. Solution:

The 9’s complement of

𝑛

− 𝑚

0

− 4