W2L1 BinaryArithmetic
W2L1 BinaryArithmetic
• Chapter 1: Z. Kohavi and N. Jha, Switching and Finite Automata Theory, 3rd
Ed., Cambridge University Press, 2010.
• Chapter 1, Sec 1.6 M. M. Mano and M. D. Ciletti, Digital Design, 5th Ed.,
Pearson Education (Signed numbers)
4/9/2020
Complement of a Number
• To simplify the subtraction operation
• N in base r having n digits, the (r - 1)’s complement of N , i.e., its
diminished radix complement, is defined as (r n - 1) – N
• The 1’s complement of a binary number is formed by changing 1’s to
0’s and 0’s to 1’s.
• The 1’s complement of 1011000 is 0100111.
Complement of a Number
• The r’s complement of an n‐digit number N in base r is as rn - N for N
!= 0 and as 0 for N = 0.
• r’s complement is obtained by adding 1 to the (r - 1)’s complement,
i.e., r n - N = [(rn - 1) – N + 1]
• 2’s complement of 0110111 is 1001001
• The 2’s complement can be formed by leaving all least significant 0’s
and the first 1 unchanged and replacing 1’s with 0’s and 0’s with 1’s in
all other higher significant digits.
Complement of a Number
• The complement of the complement restores the number to its
original value .
• the r’s complement of N is rn - N,
• the complement of the complement is rn - (rn - N) = N and is equal to the
original number
Addition of Unsigned Numbers
Subtraction of Unsigned Numbers
• Add M to the r’s complement of N. Mathematically, M + (rn – N) = M –
N + rn
• If M>= N , the end carry rn will be discarded.
• If M < N, there will no end carry. Result will be rn – (N-M). To obtain
the answer in a familiar form, take the r’s complement of the result
and place a negative sign in front.
• Substraction is performed using adder only for unsigned numbers.
Example
Signed Binary Number
• If binary number is signed, then the leftmost bit represents the sign
and the rest of the bits represent the number.
• Signed Magnitude: 10001001 (-9)
• 1’s complement: 11110110 (-9)
• 2’s complement: 11110111 (-9)
Signed Binary Number
• The signed‐2’s‐complement representation of -N is obtained by taking
the 2’s complement of the positive number N, including the sign bit.
• Signed‐2’s‐complement representation of -9: 11110111
• 2’s complement form is used for number representation in Digital
systems
Arithmetic Addition
• The addition of two signed binary numbers with negative numbers
represented in signed‐ 2’s‐complement form is obtained from the
addition of the two numbers, including their sign bits. A carry out of
the sign‐bit position is discarded.
Arithmetic Subtraction
• Subtraction of two signed binary numbers when negative numbers
are in 2’s‐complement form is simple and can be stated as follows:
• Take the 2’s complement of the subtrahend (including the sign bit) and add it
to the minuend (including the sign bit).
• A carry out of the sign‐bit position is discarded.
2’s Complement
• It is worth noting that binary numbers in the signed‐complement
system are added and subtracted by the same basic addition and
subtraction rules as unsigned numbers.
• Therefore, computers need only one common hardware circuit to
handle both types of arithmetic.
• This consideration has resulted in the signed‐complement system
being used in virtually all arithmetic units of computer systems.
Thank You