Browse Source

bitwise multiplication fonction added

remotes/origin/multiplication
fdai7930 11 months ago
parent
commit
ccb0982439
  1. 13
      src/multiplication.c
  2. 2
      src/multiplication.h

13
src/multiplication.c

@ -219,6 +219,19 @@ float power_multiply(float base, int exponent) {
return result; 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;
}

2
src/multiplication.h

@ -30,6 +30,8 @@ int fibonacci_multiply(int num, int fib);
int repeated_division_multiply(int num1, int num2); int repeated_division_multiply(int num1, int num2);
int bernoulli_multiply(int num, int bernoulli); int bernoulli_multiply(int num, int bernoulli);
float power_multiply(float base, int exponent); float power_multiply(float base, int exponent);
int bitwise_multiply(int num1, int num2);

Loading…
Cancel
Save