计算机中二进制数的表示方法都是补码吗?

绝大部分的都是。其他表示基本都已经死绝了。
■网友
正好我也在想这个问题。。。然后就开始找答案。。。发现。。。居然有两种观点(╯°口°)╯┴—┴:计算机中二进制数的表示方法都是补码吗?

好吧。。。Σ(  ̄□ ̄||)还是去书上找答案吧。。。——————————————————————————————————————————在Patterson和Hennessy老爷爷的Computer Organization and Design (Fifth Edition)中有这样的一段:计算机中二进制数的表示方法都是补码吗?

32-bit binary numbers can be represented in terms of the bit value times apower of 2:……For reasons we will shortly see, these positive numbers are called unsigned numbers.而上面的二进制表示,其实就是我们所说的原码,因此,原码用来表示unsigned numbers。接着,Patterson和Hennessy老爷爷又告诉了我们为什么要使用补码来表示signed numbers,而不是直接add a separate sign: Keep in mind that the binary bit patterns above are simply representatives of numbers. Numbers really have an infinite number of digits, with almost all being 0 except for a few of the rightmost digits. We just don’t normally show leading 0s. Hardware can be designed to add, subtract, multiply, and divide these binary bit patterns. If the number that is the proper result of such operations cannot be represented by these rightmost hardware bits, overflow is said to have occurred. It’s up to the programming language, the operating system, and the program to determine what to do if overflow occurs. Computer programs calculate both positive and negative numbers, so we need a representation that distinguishes the positive from the negative. The most obvious solution is to add a separate sign, which conveniently can be represented in a single bit; the name for this representation is sign and magnitude. Alas, sign and magnitude representation has several shortcomings. First, it’s not obvious where to put the sign bit. To the right? To the left ? Early computers tried both. Second, adders for sign and magnitude may need an extra step to set the sign because we can’t know in advance what the proper sign will be. Finally, a separate sign bit means that sign and magnitude has both a positive and a negative zero, which can lead to problems for inattentive programmers. As a result of these shortcomings, sign and magnitude representation was soon abandoned. In the search for a more attractive alternative, the question arose as to whatwould be the result for unsigned numbers if we tried to subtract a large numberfrom a small one. The answer is that it would try to borrow from a string of leading0s, so the result would have a string of leading 1s. Given that there was no obvious better alternative, the final solution was to pickthe representation that made the hardware simple: leading 0s mean positive, andleading 1s mean negative. This convention for representing signed binary numbersis called two’s complement representation(二进制的补码表示):


推荐阅读