Browse Source

refactoring: function addition rename variable

master
Dennis Sperzel 11 months ago
parent
commit
86319a9502
  1. 18
      src/addition.c

18
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;
}
Loading…
Cancel
Save