![]() |
VOOZH | about |
Booth's algorithm is a multiplication algorithm that multiplies two signed binary numbers in 2's complement notation.
Booth used desk calculators that were faster at shifting than adding and created the algorithm to increase their speed. Booth’s algorithm is of interest in the study of computer architecture. Here's the implementation of the algorithm.
Examples:
Input : 0110, 0010 Output : qn q[n+1] AC QR sc(step count) initial 0000 0010 4 0 0 rightShift 0000 0001 3 1 0 A = A - BR 1010 rightShift 1101 0000 2 0 1 A = A + BR 0011 rightShift 0001 1000 1 0 0 rightShift 0000 1100 0 Result=1100
Algorithm :
Put multiplicand in BR and multiplier in QR
and then the algorithm works as per the following conditions :
1. If Qn and Qn+1 are same i.e. 00 or 11 perform arithmetic shift by 1 bit.
2. If Qn Qn+1 = 01 do A= A + BR and perform arithmetic shift by 1 bit.
3. If Qn Qn+1 = 10 do A= A - BR and perform arithmetic shift by 1 bit.
Output :
qn q[n + 1] BR AC QR sc initial 0000 1010 4 0 0 rightShift 0000 0101 3 1 0 A = A - BR 1010 rightShift 1101 0010 2 0 1 A = A + BR 0011 rightShift 0001 1001 1 1 0 A = A - BR 1011 rightShift 1101 1100 0 Result = 1100
Time Complexity: O(n)
Auxiliary Space: O(1)