Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在2006 年混淆 C 代码竞赛中。请解释 sykes2.c,
有一个声明“-~i == i+1因为二进制补码”。
-~i == i+1
有人可以解释为什么会这样吗?
-~x等于x+1因为~x等于(0xffffffff-x)。这等于(-1-x)2s 补码,-~x所以-(-1-x) = x+1.
-~x
x+1
~x
(0xffffffff-x)
(-1-x)
-(-1-x) = x+1