How can I multipy two integers using bitwise operators?
I found an implementation here. Is there a better way of implementing multiplication?
For example: 2 * 6 = 12 must be performed using bitwise operators.
NOTE: Numbers are arbitrary, not power of 2
The Wikipedia entry on bitwise operator applications has some pseudo code, but it uses the addition operator as well as bitwise operators.
In C# here is the implementation of the function.
Below is one possible solution for multiplication of two integers using bitwise operators.
Function multiply() can be slighted changed as below using Shiv's Add() function:
Assembly algorithm: This follows directly from the fact that ax*7 = (ax*8)-ax.
Every shift step is a multiplication by 2
Source