Cant make value propagate through carry
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Making a little C++ large precision class, and everything seems to work decent, but the add, if I add 0xffffffff and 0x04 together I get 0xffff0003 when I should get 0x0100000003. Here is the function with the issue: mpfl operator+(const mpfl &lhs, const mpfl &rhs) { unsigned long i; mpfl ret(0); mpfl trhs(rhs); for (i = lhs.nbytes; i >= 0; i--) { if ( (unsigned short)lhs.data[i].data + (unsigned short)trhs.data[i].data > (unsigned short)255 ) { if (i > 0) { ret.data[i].carry = 1; ret.data[0].carry = 0; } else { ret.data[0].carry = 1; } }