1.8B M1-Cis1102 Signed Binary Arithmetic
1.8B M1-Cis1102 Signed Binary Arithmetic
INTRODUCTION TO COMPUTING
SIGNED BINARY
RECALL: BINARY ARITHMETIC
It is used in digital systems mainly because the numbers (decimal and floating-
point numbers) are stored in binary format.
In most ALU (Arithmetic & Logic Unit) hardware, the operated numbers are
stored in a fixed number of bits, a typical value between 4 and 16 decimal digits
Tasks:
a) Calculate the sum of the given 8-bit signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given 8-bit signed binary numbers and their
sum. Show the complete details of the solution.
Carry 1 1 1
Augend (A) 0 1 0 0 0 1 1 1
Addend (B) 0 0 1 0 0 1 0 1
Final Sum 0 1 1 0 1 1 0 0
Weights 128 64 32 16 8 4 2 1
Binary Augend (A) 0 1 0 0 0 1 1 1
Decimal Augend (A) 64 + 4 + 2 + 1 = +71
Weights 128 64 32 16 8 4 2 1
Binary Addend (B) 0 0 1 0 0 1 0 1
Decimal Addend (B) 32 + 4 + 1 = +37
Tasks:
a) Calculate the sum of the given signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given signed binary numbers and their sum.
Show the complete details of the solution.
Carry 1 1 1 1 1
Augend (C) 0 0 1 0 0 1 1 1 . 1 1
Addend (D) 0 0 0 1 0 1 0 0 . 0 1
Final Sum 0 0 1 1 1 1 0 0 . 0 0
Tasks:
a) Calculate the sum of the given 8-bit signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given 8-bit signed binary numbers and their
sum. Show the complete details of the solution.
Carry 1 1 1 1
Augend (E) 0 0 0 1 0 1 1 1
Addend (F) 1 1 1 1 1 0 0 0
Final Sum 1 0 0 0 0 1 1 1 1
Discard
Weights 128 64 32 16 8 4 2 1
Binary Augend (E) 0 0 0 1 0 1 1 1
Decimal Augend (E) 16 + 4 + 2 + 1 = + 23
Weights 128 64 32 16 8 4 2 1
Binary Augend (E) 0 0 0 1 0 1 1 1
Decimal Augend (E) 16 + 4 + 2 + 1 = + 23
Weights -128 64 32 16 8 4 2 1
Binary Addend (F) 1 1 1 1 1 0 0 0
Decimal Addend (F) -128 + 64 + 32 + 16 + 8 = -128 + 120 = - 8
Tasks:
a) Calculate the sum of the given signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given signed binary numbers and their sum.
Show the complete details of the solution.
Carry 1 1 1 1 1 1 1 1 1
Augend (G) 0 0 1 0 0 1 1 0 . 1 1
Addend (H) 1 1 1 1 1 0 0 1 . 1 0
Final Sum 1 0 0 1 0 0 0 0 0 . 0 1
Discard
The complement of the complement restores the number to its original value.
o To see this relationship,
note that the 2’s complement of N is rn - N,
so that the complement of the complement is rn – (rn – N) = N
and is equal to the original number.
Tasks:
a) Calculate the sum of the given signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given signed binary numbers and their sum.
Show the complete details of the solution.
Carry 1 1 1 1 1
Augend (I) 0 0 0 1 0 0 0 1 . 0 1 1
Addend (J) 1 1 0 0 1 1 1 1 . 1 0 0
Final Sum 1 1 1 0 0 0 0 0 . 1 1 1
Tasks:
a) Calculate the sum of the given signed binary numbers. Show the complete details of the
solution.
b) Determine the decimal number equivalent of the given signed binary numbers and their sum.
Show the complete details of the solution.
Carry 1 1 1 1 1 1 1 1 1 1 1
Augend (K) 1 1 1 1 1 0 1 1 . 1 0 1
Addend (L) 1 1 1 1 0 1 1 1 . 0 1 1
Final Sum 1 1 1 1 1 0 0 1 1 0 0 0
Discard
Final Sum 1 1 1 1 0 0 1 1 . 0 0 0
Remove radix point 1 1 1 1 0 0 1 1 0 0 0
2’s Complement of Sum 0 0 0 0 1 1 0 1 . 0 0 0
When both numbers are positive or both numbers are negative and the
result has the opposite sign
Given:
M = 01111101
N = 00111010
Tasks:
a) Calculate the sum of the given 8-bit signed binary numbers and check for an overflow. Show
the complete details of the solution.
b) Determine the decimal number equivalent of the given 8-bit signed binary numbers and their
sum to countercheck the result of Task (a). Show the complete details of the solution.
a) Calculate the sum of the given 8-bit signed numbers and check for an overflow. Show the complete details of
the solution.
Carry 1 1 1 1
Augend (M) 0 1 1 1 1 1 0 1
Addend (N) 0 0 1 1 1 0 1 0
Final Sum 1 0 1 1 0 1 1 1
Counterchecking
Given:
O = 10001001
P = 10111010
Tasks:
a) Calculate the sum of the given 8-bit signed binary numbers and check for an overflow. Show
the complete details of the solution.
b) Determine the decimal number equivalent of the given 8-bit signed binary numbers and their
sum to countercheck the result of Task (a). Show the complete details of the solution.
a) Calculate the sum of the given 8-bit signed numbers and check for an overflow. Show the complete details of
the solution.
Carry 1 1 1
Augend (O) 1 0 0 0 1 0 0 1
Addend (P) 1 0 1 1 1 0 1 0
Final Sum 1 0 1 0 0 0 0 1 1
Discard
Counterchecking
RECALL
The direct method of subtraction taught in elementary schools uses the borrow concept.
o 1 is borrowed from a higher significant position when the minuend digit is smaller
than the subtrahend digit
The method works well when people perform subtraction with paper and pencil.
However, when subtraction is implemented with digital hardware, the method is less
efficient than the method that uses complements.
Algorithm:
(110101)2 - (101110)2
Tasks:
a) Find the difference of the given signed numbers using 2’s Complement
Method. Show the complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details of the solution.
Minuend 1 1 0 1 0 1
Weights -32 16 8 4 2 1
Decimal Equivalent -32 + 16 + 4 + 1 = -32 + 21 = -11
Subtrahend 1 0 1 1 1 0
Weights -32 16 8 4 2 1
Decimal Equivalent -32 + 8 + 4 + 2 = -32 + 14 = -18
Difference 0 0 0 1 1 1
Weights 32 16 8 4 2 1
Decimal Equivalent 4 + 2 + 1 = +7
Final Answer: (-11) – (-18) = (-11 + 18) = +7
Given:
(101110)2 - (110101)2
Tasks:
a) Find the difference of the two signed binary numbers given above using 2’s
Complement Method. Show the complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details of the solution.
Minuend 1 0 1 1 1 0
Weights -32 16 8 4 2 1
Decimal Equivalent -32 + 8 + 4 + 2 = -32 + 14 = -18
Subtrahend 1 1 0 1 0 1
Weights -32 16 8 4 2 1
Decimal Equivalent -32 + 16 + 4 + 1 = -32 + 21 = -11
Difference 1 1 1 0 0 1
Weights -32 16 8 4 2 1
Decimal Equivalent -32 + 16 + 8 + 1 = -32 + 25 = -7
Final Answer: (-18) – (-11) = (-18 + 11) = -7
Algorithm:
(110101)2 - (101110)2
Tasks:
a) Find the difference of the two signed binary numbers given above using 1’s
Complement Method. Show the complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details solution.
Counterchecking
Minuend 1 1 0 1 0 1
Weights -31 16 8 4 2 1 Weight of Sign Bit:
Decimal Equivalent -31 + 16 + 4 + 1 = -31 + 21 = -10
W = (-2n + 1)
Subtrahend 1 0 1 1 1 0
Weights -31 16 8 4 2 1 || n = 5 (position) ||
Decimal Equivalent -31 + 8 + 4 + 2 = -31 + 14 = -17
W = (-25 + 1)
Difference 0 0 0 1 1 1 W = (-32 + 1)
Weights 32 16 8 4 2 1 W = (-31)
Decimal Equivalent 4 + 2 + 1 = +7
Given:
(101110)2 - (110101)2
Tasks:
a) Find the difference of the two signed binary numbers given above using 1’s
Complement Method. Show the complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details of the solution.
a) Find the difference of the two signed binary numbers given above using 1’s Complement Method. Show the
complete solution.
Counterchecking
Subtrahend 1 1 0 1 0 1
Weights -31 16 8 4 2 1
Decimal Equivalent -31 + 16 + 4 + 1 = -31 + 21 = -10
Difference 1 1 1 0 0 0
Weights -31 16 8 4 2 1
Decimal Equivalent -31 + 16 + 8 = -31 + 24 = -7
Algorithm:
3. Then take the 2’s complement of the result if and only if the sign of the
two original numbers differed from each other.
Given:
(1110)2 x (0101)2
Tasks:
a) Find the product of the two signed binary numbers given above using 2’s
Complement Method. Express the partial products and the final result in 8 bits.
Show the complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details of the solution.
Multiplicand Original 1 1 1 0
Multiplicand (+) 0 0 1 0
Multiplier x 0 1 0 1
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0
Partial Products
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
Final Product (FP) Original 0 0 0 0 1 0 1 0
FP (2’s Complement) 1 1 1 1 0 1 1 0
Multiplicand 1 1 1 0
Weights -8 4 2 1
Decimal Equivalent -8 + 4 + 2 = -8 + 6 = -2
Multiplier 0 1 0 1
Weights 8 4 2 1
Decimal Equivalent 4 + 1 = +5
Final Product 1 1 1 1 0 1 1 0
Weights -128 64 32 16 8 4 2 1
Decimal Equivalent -128 + 64 + 32 + 16 + 4 + 2 = -128 + 118 = -10
Given:
Q = (-5)10
R = (-6)10
Tasks:
a) Find the product of Q and R, expressed in 4 bits each, using 2’s Complement
Method. Express the partial products and the final result in 8 bits. Show the
complete details of the solution.
b) Compute the decimal number equivalent of the given numbers and their
difference. Show the complete details of the solution.
Multiplicand 1 0 1 1
Weights -8 4 2 1
Decimal Equivalent -8 + 2 + 1 = -8 + 3 = -5
Multiplier 1 0 1 0
Weights -8 4 2 1
Decimal Equivalent -8 + 2 = -6
Final Product 0 0 0 1 1 1 1 0
Weights 128 64 32 16 8 4 2 1
Decimal Equivalent 16 + 8 + 4 + 2 = +30
Perform the division operation using the Restoring Division Flowchart and
Algorithm for signed numbers
where:
R = Remainder
D = Dividend
V = DiVisor
Q = Quotient
3. Perform A ← A – M
• since M = 2’s complement of the original divisor, thus, perform A ← A + M
5. Repeat steps 2 through 4 as many times as there are n bit positions in Q (dividend).
Given:
S = (-5)10
T = (-2)10
Task:
Find the quotient and remainder of dividing S by T using the procedure of
performing division with negative numbers.
• Express the dividend in 8 bits (load to A & Q)
• Express the divisor in 4 bits (load 2’s complement of +T to M)
• Show the sequence of events of the operation
• Express the final answer in decimal and binary forms
A Q M n
(Q3Q2Q1Q0) Signs:
0000 0101 1110 4 Initial Values
Sign(Q) = Sign(D) x Sign(V)
0000 1010 1110 3 Shift Left A,Q
1110 1010 1110 A ← A + M; MSB(A) = 1
Sign(Q) = (-) x (-) = (+)
0000 1010 1110 Restore Previous A ; Set Q0 = 0
Sign(R) = Sign(D)
0001 0100 1110 2 Shift Left A,Q
1111 0100 1110 A ← A + M; MSB(A) = 1
Sign(R) = (-)
0001 0100 1110 Restore Previous A ; Set Q0 = 0
0010 1000 1110 1 Shift Left A,Q Final Answer:
0000 1000 1110 A ← A + M; MSB(A) = 0
0000 1001 1110 Set Q0 = 1
Q: Quotient = (+2)10 = 00102
0001 0010 1110 0 Shift Left A,Q A: Remainder = (-1)10 = 11112
1111 0010 1110 A ← A + M; MSB(A) = 1
0001 0010 1110 Restore Previous A ; Set Q0 = 0
Given:
U = (+7)10
V = (+3)10
Task:
Find the quotient and remainder of dividing U by V using the procedure
of performing division with negative numbers.
• Express the dividend in 8 bits (load to A & Q)
• Express the divisor in 4 bits (load 2’s complement of +V to M)
• Show the sequence of events of the operation
• Express the final answer in binary and decimal forms
A Q M n
(Q3Q2Q1Q0) Signs:
0000 0111 1101 4 Initial Values
Sign(Q) = Sign(D) x Sign(V)
0000 1110 1101 Shift Left A,Q
1101 1110 1101 A ← A + M; MSB(A) = 1
Sign(Q) = (+) x (+) = (+)
0000 1110 1101 3 Restore Previous A ; Set Q0 = 0
Sign(R) = Sign(D)
0001 1100 1101 Shift Left A,Q
1110 1100 1101 A ← A + M; MSB(A) = 1
Sign(R) = (+)
0001 1100 1101 2 Restore Previous A ; Set Q0 = 0
0011 1000 1101 Shift Left A,Q Final Answer:
0000 1000 1101 A ← A + M; MSB(A) = 0
0000 1001 1101 1 Set Q0 = 1 Q: Quotient = 00102 = +210
0001 0010 1101 Shift Left A,Q A: Remainder = 00012 = +110
1110 0010 1101 A ← A + M; MSB(A) = 1
0001 0010 1101 0 Restore Previous A ; Set Q0 = 0
Given:
W = (+6)10
X = (- 3)10
Task:
Find the quotient and remainder of dividing W by X using the procedure
of performing division with negative numbers.
• Express the dividend in 8 bits (load to A & Q)
• Express the divisor in 4 bits (load 2’s complement of +X to M)
• Show the sequence of events of the operation
• Express the final answer in binary and decimal forms
THANK YOU!