Created
June 17, 2018 00:28
-
-
Save finomayato/8c2ead5c4cf7f898cc598c66cd725e62 to your computer and use it in GitHub Desktop.
High-level implementation of binary adding machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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