From 86319a95029d1aae3f13ef94799e887a0c0aab1e Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Thu, 1 Feb 2024 08:09:59 +0100 Subject: [PATCH] refactoring: function addition rename variable --- src/addition.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/addition.c b/src/addition.c index d165ae4..d56f705 100644 --- a/src/addition.c +++ b/src/addition.c @@ -7,19 +7,19 @@ void full_adder (unsigned int* sum, unsigned int* nextcarry, unsigned int number nextcarry[0] = ((number1 % 2) & (number2 % 2)) | ((number1 % 2) & (carry % 2)) | ((number2 % 2) & (carry % 2)); } -unsigned int addition(unsigned int a, unsigned int b) { - unsigned int erg = 0; - unsigned int s[1] = {0}; - unsigned int nc[1] = {0}; +unsigned int addition(unsigned int number1, unsigned int number2) { + unsigned int result = 0; + unsigned int sum[1] = {0}; + unsigned int nextcarry[1] = {0}; for (int i = 0; i < 2; i++) { - full_adder(s, nc, a, b, nc[0]); - erg ^= (s[0] << i); + full_adder(sum, nextcarry, number1, number2, nextcarry[0]); + result ^= (sum[0] << i); - a >>= 1; - b >>= 1; + number1 >>= 1; + number2 >>= 1; } - return erg; + return result; } \ No newline at end of file