BINARY ARITHMETIC (Base 2)
Addition:
0+0=0
0+1=1
1+0=1
1 + 1 = 0 and carry 1 to the next column
Ex: 1101
+ 1011
Subtraction:
0–0=0
0 – 1 = 1 and borrow 1 from the next column
1–0=1
1–1=0
Ex: 11101
– 10011
Multiplication:
0×0=0
0×1=0
1×0=0
1×1=1
Ex: 111
× 101
12
SUBTRACTION USING COMPLEMENTS
Subtraction with Unsigned Numbers:
Using (r-1)’s complement:
The subtraction of two n-digit unsigned numbers M − N in base r can be done as
follows:
1. Add the minuend M to the (r − 1)’s complement of the N. This performs M + [(rn − 1) − N].
2. If M ≥ N + 1, the sum will produce an end carry which is discarded and a 1 is added to the sum.
3. If M < N + 1, the sum does not produce an end carry and is equal to (rn − 1) − (N − M), which is
the (r − 1)’s complement of (N − M). To obtain the answer, take the (r − 1)’s complement of the
sum and place a negative sign in front.
Ex: Using 1’s complement perform (1010100)2 – (1000011)2.
Ex: Using 1’s complement perform (1000011)2 – (1010100)2.
13
Using r’s complement:
The subtraction of two n-digit unsigned numbers M − N in base r can be done as
follows:
1. Add the minuend M to the r’s complement of the N. This performs M + [rn − N].
2. If M ≥ N, the sum will produce an end carry which is discarded; what is left is the result M − N.
3. If M < N, the sum does not produce an end carry and is equal to rn − (N − M), which is the r’s
complement of (N − M). To obtain the answer, take the r’s complement of the sum and place a
negative sign in front.
Ex: Using 2’s complement perform (1010100)2 – (1000011)2.
Ex: Using 2’s complement perform (1000011)2 – (1010100)2.
14
Subtraction with Signed Numbers:
Negative numbers are represented in different ways:
1. Signed-Magnitude
2. 1's Complement
3. 2's Complement
Ex: Consider the number 9 in binary with 8 bits:
Signed-Magnitude 1’s Complement 2’s Complement
+9 —> _______________ _______________ _______________
–9 —> _______________ _______________ _______________
The subtraction of two n-digit signed numbers M − N in base 2 can be done follows:
1. Take the 2’s complement of the subtrahend, N, (including the sign bit),
2. and add it to the minuend, M, (including the sign bit).
3. A carry out of the sign bit is discarded.
Ex: Using 2’s complement perform (–6) – (–13).
Ex: Using 2’s complement perform (+4) – (+8).
15