Skip to content

Instantly share code, notes, and snippets.

@finomayato
Created June 17, 2018 00:28
Show Gist options
  • Save finomayato/8c2ead5c4cf7f898cc598c66cd725e62 to your computer and use it in GitHub Desktop.
Save finomayato/8c2ead5c4cf7f898cc598c66cd725e62 to your computer and use it in GitHub Desktop.
High-level implementation of binary adding machine
#include <stdio.h>
int main() {
unsigned int param_1 = 5, param_2 = 8;
unsigned int sum, carry;
sum = param_1 ^ param_2;
carry = param_1 & param_2;
for (int i = 0; i < sizeof(carry); i ++) {
carry <<= 1;
param_1 = sum;
param_2 = carry;
sum = param_1 ^ param_2;
carry = param_1 & param_2;
}
printf("%u\n", sum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment