diff --git a/src/multiplication.c b/src/multiplication.c index 0734802..062c50b 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -219,6 +219,19 @@ float power_multiply(float base, int exponent) { return result; } +int bitwise_multiply(int num1, int num2) { + int result = 0; + while (num1) { + if (num1 & 1) { + result += num2; + } + num1 >>= 1; + num2 <<= 1; + } + return result; +} + + diff --git a/src/multiplication.h b/src/multiplication.h index c29b077..342bd91 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -30,6 +30,8 @@ int fibonacci_multiply(int num, int fib); int repeated_division_multiply(int num1, int num2); int bernoulli_multiply(int num, int bernoulli); float power_multiply(float base, int exponent); +int bitwise_multiply(int num1, int num2); +