Russian Peasant method - Multiplication with Doubling and Halving why it works?
Russian Peasant method
Given 2 Number, 1st Number need to be doubled and 2nd number need to be halved.
Until the halved number becomes zero.
Whenever reminder occurs during halving take the first doubling number and note it down separately.
Add all the noted numbers. It is the required multiplication result.
How is it useful?
It is useful to make use of bitwise operator in algorithms instead of ALUs. Right shift halves and left shift doubles and reminder check can be done with bitwise AND operator.
Very useful in Assembly language programming to do multiplication.
Why does it work?
We can see multiplication as increasing one entity with another entity.
When we multiply one number by 2 and we are dividing another number by 2. Thereby we are balancing and equating the operations on 2 numbers.
When the reminder arrives, 1*doubling number is kept separately and 1 is reduced from halving number. 1 times doubling number is kept separately to keep the balance or equating stuff.
Anyway when we keep halving last reminder will be always one, even if the second halving number is even.
It is a math magic for multiplication operation.
Comments
Post a Comment