Browse Source

Refactoring:remove fontion multi_by_riesel_prime

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

14
src/multiplication.c

@ -48,14 +48,14 @@ int multi_by_sum(int num1, int num2) {
return num1 * (num2 + 1); return num1 * (num2 + 1);
} }
int multi_using_two_complements(int num1, int num2) {
int multi_using_two_complements(int num2, int num3) {
int result = 0; int result = 0;
while (num1 != 0) { while (num1 != 0) {
if (num1 & 1) {
result += num2;
if (num2 & 2) {
result += num3;
} }
num1 >>= 1;
num2 <<= 1;
num1 >>= 2;
num2 <<= 2;
} }
return result; return result;
} }
@ -255,9 +255,7 @@ int karatsuba_multi(int num1, int num2) {
return ac * (int)pow(10, 2 * m2) + ad_bc * (int)pow(10, m2) + bd; return ac * (int)pow(10, 2 * m2) + ad_bc * (int)pow(10, m2) + bd;
} }
int multi_by_riesel_prime(int num) {
return (num << 2) + (num << 3) - (num << 1) - num;
}

5
src/multiplication.h

@ -10,7 +10,7 @@ float multi_by_percentage(float num, float percentage);
int multi_by_random(int num); int multi_by_random(int num);
int multi_string(const char* str, int factor); int multi_string(const char* str, int factor);
int multi_by_sum(int num1, int num2); int multi_by_sum(int num1, int num2);
int multi_using_two_complements(int num1, int num2);
int multi_using_two_complements(int num2, int num3);
int multi_by_even(int num, int factor); int multi_by_even(int num, int factor);
int multi_using_lookup_table(int num1, int num2); int multi_using_lookup_table(int num1, int num2);
int multi_using_logical_operations(int num1, int num2); int multi_using_logical_operations(int num1, int num2);
@ -32,7 +32,8 @@ int bernoulli_multi(int num, int bernoulli);
float power_multi(float base, int exponent); float power_multi(float base, int exponent);
int bitwisee_multi(int num1, int num2); int bitwisee_multi(int num1, int num2);
int karatsuba_multi(int num1, int num2); int karatsuba_multi(int num1, int num2);
int multi_by_riesel_prime(int num);

Loading…
Cancel
Save