DSD Lecture 4
DSD Lecture 4
(EC303PC)
LECTURE-4: Binary Arithmetic
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
• 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)
01010000 01010000
Subtraction with Complements
• Example
– Using 10's complement, subtract 3250 – 72532.
• 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.