0% found this document useful (0 votes)
13 views18 pages

DSD Lecture 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views18 pages

DSD Lecture 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

DIGITAL SYSTEM DESIGN

(EC303PC)
LECTURE-4: Binary Arithmetic

Dept. of ECE, GNIT


Binary Subtraction
Rules for Binary Subtraction:

A B Difference Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Binary Subtraction

0
1 1 1 0 1 = 29
− 1 0 0 1 1 = 19

0 1 0 1 0 = 10
Binary Multiplication
• Bit by bit
1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
Binary Division
Signed Binary Numbers
• We have positive and negative numbers in the
real number system.
• Similarly, the same logic is also applied in the
binary number system as well!
• We use the Sign-Magnitude Form to represent
signed numbers.
• The corresponding number, after sign
representation, has both the sign bit as well as
the magnitude of the entire number.
Sign Magnitude Format
• If we have an n-bit binary number, one of the bits is the
sign bit. The remaining (n-1) bits in the binary number
represent the magnitude.
• This sign bit represents whether the binary number is
positive or negative.
• The binary number system has only two values i.e., 0 and
1.
• Thus, we signify the positive/negative sign using these
two digits itself.
• If the sign bit’s value is 0, then the given binary number is
a positive one.
• Alternatively, if the sign bit’s value is a 1, the given
binary number is a negative number.
• Usually, the sign bit is always the left most bit, which is
the Most Significant Bit (MSB).
Sign Magnitude Format
• Consider a system having the word length is 8 bits (i.e. a byte).
• We shall represent the number 44 in its signed representation.
• We can write 44 in binary as (101100)2.
• We represent the positive signed binary number of the
real number 44, as shown below.
Sign Magnitude Format

• We represent the negative signed binary


number of the real number -44, as shown
below.
NOTE
• In the case of unsigned n-bit binary numbers
the range is 0 to 2n – 1.
• For n= 8 bits, the range is
0 to 28 – 1 =0 to 255.
• In the case of signed n-bit binary numbers the
range is -(2n-1 – 1) to +(2n-1 – 1).
• For n= 8 bits, the range is
-(27 – 1) to + (27 – 1) = -127 to +127.
Complements of Numbers
• There are two types of complements for each base-r system:
the radix complement and diminished radix complement.

• 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

• Example for 6-digit decimal numbers:


– 9’s complement is (rn – 1)–N = (106–1)–N = 999999–N
– 9’s complement of 546700 is 999999–546700 = 453299
Complements of Numbers

• Example for 7-digit binary numbers:


 1’s complement is (rn – 1) – N = (27–1)–N = 1111111–N
 1’s complement of 1011000 is 1111111–1011000
= 0100111

• 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
1’s Complement (Diminished Radix
Complement)
 All ‘0’s become ‘1’s
 All ‘1’s become
‘0’s Example
(10110000)2
 (01001111)2
If you add a number and its 1’s complement …

10110000
+ 0100111
11111111
Radix Complement
The r's complement of an n-digit number N in base r is defined
as rn – N for N ≠ 0 and as 0 for N = 0.
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.
• Example: Base-10
The 10's complement of 012398 is 987602
The 10's complement of 246700 is 753300

• Example: Base-2
The 2's complement of 1101100 is 0010100
The 2's complement of 0110111 is 1001001
2’s Complement (Radix Complement)

– Take 1’s complement then add 1


OR – Toggle all bits to the left of the first ‘1’ from
the right
Example:
Number: 10110000
1’s Comp.: 10110000
01001111
+ 1

01010000 01010000
Subtraction with Complements

– The subtraction of two n-digit unsigned numbers


M – N in base r can be done as follows:
Subtraction with Complements
• Example
– Using 10's complement, subtract 72532 – 3250.

• Example
– Using 10's complement, subtract 3250 – 72532.

There is no end carry.

Therefore, the answer is – (10's complement of 30718) =  69282.


Subtraction with Complements

• Example
– Given the two binary numbers X = 1010100
and Y = 1000011, perform the subtraction (a) X
– Y ; and (b) Y  X, by using 2's complement.

There is no end carry. Therefore, the answer is


Y – X =  (2's complement
of 1101111) =  0010001.

You might also like