#include <stdio.h>
#include <stdbool.h>
#define ARRAY_SIZE 64
bool add_Two_Bin_Number(int * array1,int * array2,int * array3){
int carry_in_flag = 0;
int tmp;
__int64_t i;
for(i = ARRAY_SIZE - 1;i >= 0;i -- )
{
tmp = array1[i] + array2[i] + carry_in_flag;
if(tmp / 2)
carry_in_flag = 1;
else
carry_in_flag = 0;
array3[i + 1] = tmp % 2;
}
if(carry_in_flag)
array3[i + 1] = carry_in_flag;
else
array3[i + 1] = 0;
return true;
}
bool digit_to_binary(const __int64_t num,int * array )
{
__int64_t tmp1,tmp2,tmp3;
int i = ARRAY_SIZE - 1;
tmp1 = num;
do{
// printf("dividend:%d\n",tmp1);
tmp2 = tmp1 / 2;
// printf("quotient:%d\n",tmp2);
tmp3 = tmp1 % 2;
// printf("remainder:%d\n",tmp3);
array[i] = tmp3;
i --;
tmp1 = tmp2;
}while(tmp2 > 0 && i >= 0);
}
int main() {
int array1[ARRAY_SIZE] = {0};
int array2[ARRAY_SIZE] = {0};
int array3[ARRAY_SIZE + 1] = {0};
digit_to_binary(18320925851,array1);
digit_to_binary(18682904472,array2);
add_Two_Bin_Number(array1,array2,array3);
int j = -1;
for(int i = 0 ; i <= ARRAY_SIZE; i ++)
{
printf("%d",array3[i]);
j ++;
if(!(j % 4))
printf(" ");
}
return 0;
}