Download presentation
Presentation is loading. Please wait.
Published byMaría Soledad Salas Modified over 5 years ago
1
Chapter 1 (Part b) Digital Systems and Binary Numbers
Digital Logic Design Chapter 1 (Part b) Digital Systems and Binary Numbers Originally by T.Tasniem Nasser Al-Yahya
2
Outline of Chapter 1 (Part b)
1.5 Complements
3
Complements Complements are used in digital computers to simplify the subtraction operation and for logical manipulation. Simplifying operations leads to simpler , less expensive circuits to implement the operations.
4
1.5 Complements There are two types of complements for each base-r system: Diminished Radix Complement - (r-1)’s Complement. Radix Complement - (r)’s Complement.
5
Complements Diminished Radix Complement-(r-1)’s Complement
Given a number N in base r having n digits, the (r–1)’s complement of N is defined as: (rn –1) – N
6
Complements Diminished Radix Complement-(r-1)’s Complement
Example for 6-digit decimal numbers: Example for 7-digit binary numbers: Observation: Subtraction from (rn – 1) will never require a borrow Diminished radix complement can be computed digit-by-digit For binary: 1 – 0 = 1 and 1 – 1 = 0 Subtract each digit from 9 9’s complement of is – = Subtract each digit from 1 (1-0=1, 1-1=0) 1’s complement of is – =
7
Complements Diminished Radix Complement-(r-1)’s Complement
1’s Complement (Diminished Radix Complement) All ‘0’s become ‘1’s All ‘1’s become ‘0’s Example ( )2 ( )2 If you add a number and its 1’s complement …
8
Complements Radix Complement-(r)’s Complement
Given a number N in base r having n digits, the (r)’s complement of N is defined as: Comparing with the (r 1) 's complement, we note that the r's complement is obtained by adding 1 to the (r 1) 's complement, since rn – N = [(rn 1) – N] + 1.
9
Complements Radix Complement-(r)’s Complement
Example: Base-10 Example: Base-2 Observation: For binary: starting from right to left keep all the zeroes unchanged and toggle all bits to the left of the first ‘1’. The 10's complement of is ( 9's complement+1) The 10's complement of is The 2's complement of is ( 1's complement+1) The 2's complement of is
10
Complements Subtraction using Complements
When subtraction is implemented with digital hardware it is more efficient to use complements. Procedure for subtracting two n-digit unsigned numbers M – N in base r : Line up the numbers from right to left. If one number is shorter extend it by adding leading zeros to the front of the number. (my notes) Add minuend M to the r's complement of the subtrahend N. This performs M + (rn - N)
11
Complements subtraction using Complements
If M >= N, the sum will produce an end carry rn which is discarded, and what is left is the result M - N If M < N, the sum does not produce an end carry. It is equal to the r's complement of (M - N). The correct answer is generated by taking the r's complement of the answer then adding a negative sign to the front Overflow
12
Complements subtraction using Complements
Example 1.7 Given the two binary numbers X = and Y = , perform the subtraction (a) X – Y ; and (b) Y X, by using 2's complement. Discard carry There is no end carry. To clarify, the answer is Y – X = (2's complement of ) =
13
Reading Chapter 1: 1.5
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.