This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
Obfuscated C Code Contest 2006. Please explain sykes2.c中,

有一个语句“ -~i == i+1因为二进制补码”。

有人可以解释为什么会这样吗?

最佳答案

-~x等于x+1,因为~x等同于(0xffffffff-x)。这等于2秒补码中的(-1-x),因此-~x-(-1-x) = x+1

10-07 19:40
查看更多