Browse Source

multiplication hex numbers

remotes/origin/multiplication
fdai7930 11 months ago
parent
commit
6ff0b7ab18
  1. 14
      src/multiplication.c
  2. 1
      src/multiplication.h

14
src/multiplication.c

@ -159,9 +159,23 @@ int multiply_octal_numbers(int num1, int num2) {
num1 <<= 3; // Décalage octal num1 <<= 3; // Décalage octal
num2 >>= 1; num2 >>= 1;
} }
return result; return result;
} }
int multiply_hex_numbers(int num1, int num2) {
int result = 0;
while (num2 != 0) {
if (num2 & 1) {
result += num1;
}
num1 <<= 4; // Décalage hexadécimal
num2 >>= 1;
}
return result;
}

1
src/multiplication.h

@ -23,6 +23,7 @@ int multiply_using_binary_enumeration(int num1, int num2);
int multiply_using_differences(int num1, int num2); 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);
#endif // MULTIPLICATION_H #endif // MULTIPLICATION_H

Loading…
Cancel
Save