我想获得在 c 中添加两个无符号 64 位整数的进位位。如果需要,我可以使用 x86-64 asm。代码:
#include <stdio.h>
typedef unsigned long long llu;
int main(void){
llu a = -1, b = -1;
int carry = /*carry of a+b*/;
llu res = a+b;
printf("a+b = %llu (because addition overflowed), carry bit = %d\n", res, carry);
return 0;
}