Browse Source

multiplication of exponentiation added

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

13
src/multiplication.c

@ -169,12 +169,23 @@ int multiply_hex_numbers(int num1, int num2) {
if (num2 & 1) { if (num2 & 1) {
result += num1; result += num1;
} }
num1 <<= 4; // Décalage hexadécimal
num1 <<= 4;
num2 >>= 1; num2 >>= 1;
} }
return result; return result;
} }
int multiply_exponentiation(int base, int exponent) {
int result = 1;
while (exponent > 0) {
if (exponent & 1) {
result *= base;
}
base *= base;
exponent >>= 1;
}
return result;
}

1
src/multiplication.h

@ -24,6 +24,7 @@ int multiply_using_differences(int num1, int num2);
int multiply_recursive_optimized(int num1, int num2); int multiply_recursive_optimized(int num1, int num2);
int multiply_octal_numbers(int num1, int num2); int multiply_octal_numbers(int num1, int num2);
int multiply_hex_numbers(int num1, int num2); int multiply_hex_numbers(int num1, int num2);
int multiply_exponentiation(int base, int exponent);
#endif // MULTIPLICATION_H #endif // MULTIPLICATION_H

Loading…
Cancel
Save