You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
724 B

#include "addition.h"
#include <stdlib.h>
void full_adder (num* sum, num* nextcarry, num number1, num number2, num carry) {
sum[0] = (number1 % 2) ^ (number2 % 2) ^ (carry % 2);
nextcarry[0] = ((number1 % 2) & (number2 % 2)) | ((number1 % 2) & (carry % 2)) | ((number2 % 2) & (carry % 2));
}
unsigned int addition(num number1, num number2) {
unsigned int result = 0;
num sum[1] = {0};
num nextcarry[1] = {0};
for (int i = 0; i < 8 * sizeof(num); i++)
{
full_adder(sum, nextcarry, number1, number2, nextcarry[0]);
result ^= (sum[0] << i);
number1 >>= 1;
number2 >>= 1;
}
return result;
}
float addition_float(float a, float b) {
return 0.0;
}