Binary Arithmetic
Binary Addition
Binary Subtraction
Binary Multiplication
Binary Division
Binary Addition
Two binary numbers are added by adding each pair of bits
together with carry propagation.
0+0=0 with a carry of 0
0+1=1 with a carry of 0
1+0=1 with a carry of 0
1 + 1 = 10 with a carry of 1
Binary Addition
Example 1:
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
◼ Two binary numbers are subtracted by subtracting
each pair of bits together with borrowing, if needed.
❑ 0–0=0
❑ 1–1=0
❑ 1–0=1
❑ 10 – 1 = 1
Binary Subtraction
Example 3:
1 0 1 5
- 1 1 - 3
1 0 2
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.
• For decimal numbers, r = 10 and r - 1 = 9, so the 9’s complement of N is (10n - 1) -
N. In this case, 10n represents a number that consists of a single 1 followed by n 0’s.
10n - 1 is a number represented by n 9’s. It follows that the 9’s complement of a
decimal number is obtained by subtracting each digit from 9.
• For example:
the 9’s complement of 524700 is 999999 - 546700 = 475299.
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
Signed-1’s Complement Representation
In the 1’s complement scheme, an n-bit negative number, K, is obtained by finding the 1’s
complement of its equivalent positive number, P.
For example, consider the number P=+5, represented in binary with eight bits.
P=00000101
If we convert +5 to a negative, we get −5 =K=11111010
Signed-2’s Complement Representation
In the 2’s complement scheme, a negative number, K, is obtained by finding the 2’s
complement of its equivalent positive number, P.
Using our eight-bit example, −5 =k= 11111011
Represents numbers from −2𝑛−1 to 2𝑛−1 − 1; where n is number of bits.
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.
2’s Complement Addition
o 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.
• Consider the combinations
➔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
Subtraction operation can be realized as
the addition operation, using a 2’s
complement of the subtrahend,
regardless of the signs of the two
operands.
Therefore, it should be possible to use
the same adder circuit to perform both
addition and subtraction.
13
Reference
Brown and Vranesic: Chapter 5
Thomas L. Floyd: Chapter 2
14