From a81f436feacb4af523e4c00c4f40d2a94924d9b3 Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Thu, 8 Feb 2024 21:58:49 +0100 Subject: [PATCH] replaced num1 with num2 in multi_using_two_complements --- src/multiplication.c | 9 +++++---- src/multiplication.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index 55ce189..934fa74 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -50,12 +50,12 @@ int multi_by_sum(int num1, int num2) { int multi_using_two_complements(int num2, int num3) { int result = 0; - while (num1 != 0) { - if (num2 & 2) { + while (num2 != 0) { + if (num2 & 1) { result += num3; } - num1 >>= 2; - num2 <<= 2; + num2 >>= 2; + num3 <<= 2; } return result; } @@ -262,5 +262,6 @@ int karatsuba_multi(int num1, int num2) { + diff --git a/src/multiplication.h b/src/multiplication.h index c0e9bd9..9155916 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -40,5 +40,6 @@ int karatsuba_multi(int num1, int num2); + #endif // MULTIPLICATION_H