用了9个月的iphone 6不停白屏,断线怎么办# Apple - 家有苹果
g*s
1 楼
【 以下文字转载自 Programming 讨论区 】
发信人: gandjmitbbs (Nothing), 信区: Programming
标 题: 问个bitwise实现加法的问题
发信站: BBS 未名空间站 (Thu Feb 3 01:35:27 2011, 美东)
unsigned bit_add(unsigned int x, unsigned int y) {
unsigned int carry = x & y;
unsigned int result = x ^ y;
while ( carry != 0 ) {
unsigned int shifted_carry = carry << 1;
carry = result & shifted_carry;
result ^= shifted_carry;
}
return result;
}
没想明白正确性。另外如果扩展到int怎么改?
发信人: gandjmitbbs (Nothing), 信区: Programming
标 题: 问个bitwise实现加法的问题
发信站: BBS 未名空间站 (Thu Feb 3 01:35:27 2011, 美东)
unsigned bit_add(unsigned int x, unsigned int y) {
unsigned int carry = x & y;
unsigned int result = x ^ y;
while ( carry != 0 ) {
unsigned int shifted_carry = carry << 1;
carry = result & shifted_carry;
result ^= shifted_carry;
}
return result;
}
没想明白正确性。另外如果扩展到int怎么改?