Lecture #3
Lecture #3
Binary Addition
Binary Subtraction
Binary Multiplication
Binary Division
Binary Addition
1 0 0 0 8
+ 1 1 1 + 7
1 1 1 1 15
Example 2:
Carry 1 1
1 1 3
+ 1 1 + 3
1 1 0 6
Binary Subtraction
Example 4:
Borrow 0 1 1 0 1 1 0 1
1 1 0 1 0 0 1 0 210
- 0 1 1 0 1 1 0 1 - 109
0 1 1 0 0 1 0 1 101
Binary Multiplication
◼ Reading assignment
Binary Division
◼ Reading assignment
Complements of Numbers
• Complements are used in digital computers to simplify the subtraction operation
and for logical manipulation.
• There are two types of complements for each base‐r system:
• The radix/r’s complement and the diminished radix/(r - 1)’s complement.
Diminished Radix Complement
• Given a number N in base r having n digits, the (r - 1)’s complement of N is defined
as (r n - 1) - N.
7
For binary numbers, r = 2 and r - 1 = 1, so the 1’s complement of N is (2n - 1) - N.
o Similar to the decimal case, the 1’s complement of a binary number is
obtained by subtracting each digit from 1.
o However, when subtracting binary digits from 1, we can have either
1 - 0 = 1 or 1 - 1 = 0, the bit toggles.
Example:
The 1’s complement of 1011001 is 0100110.
Radix Complement
The r’s complement of an n‐digit number N in base r is defined as r n - N for N ≠ 0
and as 0 for N = 0.
we note that the r’s complement is obtained by adding 1 to the (r - 1)’s
complement, since rn -N = [(r n- 1) - N] + 1.
Example: The 2’s complement of binary 100100 is 011011 + 1 = 011100.
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.
Example: The 2’s complement of 1101110 is 0010010
The complement of the complement restores the number to its original value .
8
Signed Binary Numbers
In the binary system the sign of a number is denoted by the left-most bit.
o For a positive number the left-most bit is equal to 0.
o For a negative number the left-most bit is equal to 1.
• Therefore, in signed numbers the left-most bit represents the sign, and the
remaining n − 1 bits represent the magnitude.
9
Negative numbers can be represented in three different ways: signed-magnitude, signed-
1’s complement, and signed-2’s complement.
Signed-Magnitude Representation
The sign bit is 0 or 1 for positive or negative numbers, respectively.
For example, if we use four-bit numbers, then +5 = 0101 and −5 = 1101
10
The table below illustrates the interpretation of all 16 four-bit patterns in the three
signed number representations. Note that for both signed-magnitude representation
and for 1’s complement representation there are two patterns that represent the value
zero. For 2’s complement there is only one such pattern. Also, observe that the range
of numbers that can be represented with four bits in 2’s complement form is −8 to
+7, while in the other two representations it is −7 to +7.
11
Arithmetic Addition
Addition can be performed in any of the three number representations.
➔The 2’s complement notation is highly suitable for the implementation of addition operations.
• Exercise: Describe overflow.
12
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.
o In the subtraction M – N, M: minuend and N: subtrahend
13
Reference
Brown and Vranesic: Chapter 5
Thomas L. Floyd: Chapter 2
14