原码, 反码, 补码

对于数学加减法场景,反码的存在意义是计算机可以用加法运算来做数学减法,但是反码不能解决 +0 和 -0 的问题,所以才有了补码。

原理看这三篇文章足以。

反码的应用场景

反码并非完全无用,它的应用场景有据可循的是在加密领域。比如这篇论文 (链接备份) 里提到他们有用反码实现加密算法。在某些加密场景下,反码运算要比补码运算更快,所以反码还是有存在意义的。

One’s complement systems are still in use. Some encryption algorithms for fast scalar arithmetic can run much faster in one’s complement than in two’s. This is mostly used in encapsulated signal processing units or real-time signal analysis systems. Because of that advantage one’s complement systems will continue to exist and get used. 参考 Quora 的回答